/ Published in: JavaScript
This is the correct markup for an inline script tag for HTML 4.01 and XHTML 1.0
Note the lack of any "language" attribute since this is deprecated.
In HTML 4, the content type is declared as CDATA, which means that entities will not be parsed.
In XHTML, the content type is declared as (#PCDATA), which means that entities will be parsed. So to avoid having to encode the data between the tag with enclose it in a CDATA section.
Some older browsers don't recgnise the CDATA tag so we "hide" them in Javascript comments "//"
This allows the page to be validated and also still work in older browsers.
Note the lack of any "language" attribute since this is deprecated.
In HTML 4, the content type is declared as CDATA, which means that entities will not be parsed.
In XHTML, the content type is declared as (#PCDATA), which means that entities will be parsed. So to avoid having to encode the data between the tag with enclose it in a CDATA section.
Some older browsers don't recgnise the CDATA tag so we "hide" them in Javascript comments "//"
This allows the page to be validated and also still work in older browsers.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!-- XHTML --> <script type="text/javascript"> //<![CDATA[ // Your unescaped Javascript here... //]]> </script> <!-- HTML 4.01 --> <script type="text/javascript"> // Your unescaped Javascript here... </script>