Skip to content Skip to sidebar Skip to footer

Last Updated Javadscripting In Xhtml

So I have this XHTML document where I have this script embedded in between the tags:

Solution 1:

The best way to deal with this, as far as validation is concerned, is to not use XHTML.

  • XHTML is more trouble than it is worth for 99%+ of cases (since most people trying to use XHTML tell browsers it is HTML and thus have to write it so it works with both XML and HTML parsers).
  • Transitional Doctypes were designed to help ease people into using CSS while CSS support was poor. That was in the 90s. CSS support hasn't been poor for a very, very long time.
  • The current standard is HTML 5. Browsers support it better than they do XHTML 1.0. You should almost certainly be using that (and not the XHTML serialisation of it either).

If you really, really want to use XHTML then read:

Which say, to paraphrase, the best way to make scripts valid in XHTML is to put them in an external JS file.

Failing that, wrap the inside of the script element with comments and CDATA markers:

<script>//<![CDATA[
   ...
   //]]></script>

Post a Comment for "Last Updated Javadscripting In Xhtml"