While working on ifupdown’s entrance page, I came across a need to use inline javascript. Normally, you don’t do this since XHTML will yell at you when the page is validated. I wanted to put Google Analytics on the page, but to do that and to have the page validate, I’d need those strange xml cdata sections that are scarcely seen around the web. (This brings up the question: why didn’t google think about that?)
Anyway, I was searching around and came across some forum. They claimed the cdata block was:
<script type="text/javascript"> <![cdata[ //..javascript.. ..here.. ]]> </script>
Now that is true, it does say cdata, but javascript probably will freak out since those aren’t even commented. So then I revised it and added comments.
<script type="text/javascript"> // <![cdata[ //..javascript.. ..here.. // ]]> </script>
Still no go. Why not? Did the w3c validator hate me that much? Nope, actually, it’s not lowercase.
<script type="text/javascript"> // <![CDATA[ //..javascript.. ..here.. // ]]> </script>
Uppercase happens to pass validation perfectly. I don’t know who’s smart idea that was, to make everything else in xml lowercase/case-sensitive, except for cdata, but it was not a good idea. Hope this will help someone out: cdata xhtml blocks are in uppercase!