Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

Your Answer


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.