Tell me more ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

Is it possible to pass w3 xhtml strict validation and still use google analytic code on my webpage?

share|improve this question
What errors do you get when you insert google analytics on your page? – Justin Dearing Oct 14 '10 at 11:48
1  
You will probably get better answers at webmasters.stackexchange.com. This site is about using existing web apps, not managing your own web site. – Al Everett Oct 14 '10 at 15:17

closed as off topic by Barry Dec 2 '11 at 8:36

Questions on Web Applications Stack Exchange are expected to relate to web applications within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

2 Answers

up vote 0 down vote accepted

Yes, w3 xhtml strict validation does not check or see Javascript.

share|improve this answer
1  
Presumably the <script> tags will need to be valid XHTML. – Al Everett Oct 14 '10 at 15:15

The <script> tag in XHTML differs slightly from the one in HTML in that its content is of type (#PCDATA), which means that entities in the tag will be parsed. Thus most non-trivial code will break XHTML validation.

To make your <script> tag valid XHTML, use syntax like this:

<script type="text/javascript">//<![CDATA[
var i=10;
if (i<5) {
    // some code
}
//]]></script>
share|improve this answer