SCRIPT and embedded markup

Obviously code like below is a nesting problem:
<script type="text/javascript">
// This should go between <head> and </head>
</script>

But the reason for there being even a mention to the invalidity of the following is astounding (from <http://www.htmlhelp.com/tools/validator/problems.html#script>:
<script type="text/javascript">
<!--
  // This is an error!
  document.write("</P>");
// -->
</script>

The purpose of commenting out the script content is to hide it from old (really old) browsers so that only newer browsers handle it. However, just because UAs stoop to the level of snooping out comments to support an outdated and improper hack does not mean a validator should.
As far as a validator that *properly* parses HTML or XML documents, the above code should be exactly identical to the following:
<script type="text/javascript">

</script>


Let me more agressively put it this way: if I used a C compiler that complained about code I had commented out, I would use a better compiler.
Just as it is valid to have
....<body>
<!-- <head><title></head></title> -->
....
it is also valid to have
<script type="image/gif">
<!-- <script> cannot be embedded within itself -->
</script>
for example.

So I recommend two things. First, that this "bug" be "fixed" since what the UAs do is irrelevent in terms of validity (I only definitely know of one browser that checks the validity of a document and that is iCab). Second, that any comments recommending additional backslash-hacks be removed. So basically that means removing that link.

Note also that amperstands do not cause hissy fits anywhere in comments. But && is not a valid character code. If the validator should be invalid, at least it should be consistently so. Also, <html> cannot go inside a script, but I get no errors with it in a comment in a script.
And <!-- </ is not a comment. This is still part of that comment way back <-- - oh, I just ended it (but it's an invalid declaration).

Do I make my point clear?

__________________________________________________________________
Switch to Netscape Internet Service.
As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register

Netscape. Just the Net You Need.

New! Netscape Toolbar for Internet Explorer
Search from anywhere on the Web and block those annoying pop-ups.
Download now at http://channels.netscape.com/ns/search/install.jsp

Received on Wednesday, 1 June 2005 00:01:24 UTC