In XHTML, unlike HTML, the script and style elements are declared as having parsed character data (#PCDATA) content — certain characters (such as <>&"') must be represented by character entity references. Wrapping the content of the script or style element within a CDATA marked section avoids having to use these references.
<script type="text/javascript">
<![CDATA[
JavaScript here
]]>
</script>
For these sections to be compatible with both the text/html (HTML) and application/xhtml+xml (XHTML) mime types the following escape strings must be used:
<script type="text/javascript">
<!--//--><![CDATA[//><!--
JavaScript code
//--><!]]>
</script>
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
CSS styles
/*]]>*/-->
</style>

Comments