Posted By

PapillonUK on 05/03/10


javascript script elment

Versions (?)

Correct sytax for the XHTML & HTML 4 tag

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

  1. <!-- XHTML -->
  2. <script type="text/javascript">
  3. //<![CDATA[
  4. // Your unescaped Javascript here...
  5. //]]>
  6. </script>
  9. <!-- HTML 4.01 -->
  10. <script type="text/javascript">
  11. // Your unescaped Javascript here...
  12. </script>

Report this snippet  


RSS Icon Subscribe to comments
Posted By: Neha99 on October 29, 2018

Easily get tutorial for where are all apps in windows 10 and how to delete these apps and programs.

You need to login to post a comment.