Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I ran my site through the W3C validator, and a bunch of errors were caused by the Google Website Optimizer javascript.

It seems weird that would happen. If I put CDATA around it, the error go away. I assume that the code will still work?

So, I'm wondering if there's ever a time it's bad to put CDATA around javascript? and Why would Google's javascript snippets not validate in the first place?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

It probably has to do with the doctype. I suspect you're using XHTML. JavaScript Contains Characters Which Can Not Exist in XHTML. Raw < and & characters are not allowed except inside of CDATA Sections. See this page for more.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.