Scripting (Online)
3 credits
01.10.11 - 05.06.11
Validating a HTML Document Containing Script Tags
Using CDATA Tags
When using javascript in a XHTML or HTML5 document, you must enclose the javascript code within the script tags within a set of CDATA tags. The CDATA tags tell any program parsing the HTML code that the "data" inside the CDATA tags is just data and should not be parsed according to the regular HTML rules. This most often has to be done to get an otherwise valid HTML page to pass validation with the W3C's HTML validator at validator.w3.org.
<script type="text/javascript"> //<![CDATA[ //Code Here //]]> </script>