[thelist] HTML Formatting/HTML Compliance (Script Tag)
Burhan Khalid
burhankh at hotmail.com
Fri Nov 30 09:50:24 CST 2001
Ben Wrote :
[..snip..]
But, if you want to validate your XHTML and still handle the really old
browsers that don't correctly support the <script> tag, use this instead:
<script language="JavaScript" type="text/javascript">
<!-- <![CDATA[
function whatever() {
// Code
}
// ]]> -->
</script>
It validates and it works in older browsers.
[.. /snip ..]
A few problems with that tip, mainly the comment tags. If you are going to
use comment tags, you HAVE to include them in the !CDATA tag, or else, your
HTML won't validate. Atleast that's what I got from the W3 :
[ ... XHTML Recommendation ... ]
Use external style sheets if your style sheet uses < or & or ]]> or --. Use
external scripts if your script uses < or & or ]]> or --. Note that XML
parsers are permitted to silently remove the contents of comments.
Therefore, the historical practice of "hiding" scripts and style sheets
within comments to make the documents backward compatible is likely to not
work as expected in XML-based implementations.
[ ... XHTML Recommendation ... ]
According to this, the line <!-- <![CDATA[ will not validate, since it has <
, and -- that are NOT escaped in the !CDATA block.
Any other thoughts on this? I might be completely off the mark, since I am
running of fumes (no sleep).
-------------------
Burhan "Moe" Khalid
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
More information about the thelist
mailing list