Is it possible to pass w3 xhtml strict validation and still use google analytic code on my webpage?
Is it possible to pass w3 xhtml strict validation a开发者_如何学Pythonnd still use google analytic code on my webpage?
Yes. If the specific code were to contain an &, >, or < (it doesn't), you would have to wrap the JavaScript in <script type="text/javascript">//<![CDATA[
and //]]></script>
(ampersands are normally reserved for XML entities, and the others are for tags).
If you serve your web page using the XHTML MIME type application/xhtml+xml
rather than the default HTML MIME type text/html
, problems may result then. Serving pages under the latter MIME type only causes reduced cross-browser compatibilty and prevents many scripts from working. Though in the long term, I would focus on HTML5 compliance rather than XHTML compliance – that's the way further development of web standards is heading.
精彩评论