Mark Parnell said:
Only because the validator ignores the COMMENTED stuff like it is supposed
to.
As I tried explain to by citing '18.3.2 Hiding script data from user
agents' a HTML validator will NOT check for script integrity.
"As HTML does not rely on a specific scripting language, document authors
must explicitly tell user agents the language of each script. This may be
done either through a default declaration or a local declaration. [...]
Documents that do not specify default scripting language information and
that contain elements that specify an intrinsic event script are incorrect."
I should mention that if the people defending this idiocy had bothered to
actually LOOK at the spec they would have found HTML 4.01 spec actually
defines what a script its:
"a program that may accompany an HTML document or be embedded directly in
it. The program executes on the client's machine when the document loads,
or at some other time such as when a link is activated. HTML's support for
scripts is independent of the scripting language."
<
http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.1>
conditional comments fit this to a 'T'. Per the specs HTML 3.2 is NOT
supposed to do scripts in ANY manner while HTML 4.01 is. Per 4.01 specs:
1) ALL scripts MUST use the script element.
2) The Type=content-type [CI] element is REQUIRED for ANY script.
3) From the examples given it is clear that a character particular
to that scripting lanuage MUST be used to comment out the ending -->
if the script is commented out so older browsers do not
renderer it as text.
4) Must take note of KNOWN issues
"Some browsers close comments on the first ">" character, so to hide script
content from such browsers, you can transpose operands for relational and
shift operators (e.g., use "y < x" rather than "x > y") or use scripting
language-dependent escapes for ">"."
<
http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.3.2>
Back to the idiotic NONSPEC example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<title>Example</title>
<body><!--[if gte IE 5]><input type example><![endif]--></body>
and get it closer to following HTML 4.01 specs.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<title>Example</title>
<body>
<SCRIPT type="text/conditionalcomment">
<!--[if gte IE 5]>
<input type example>
<![endif]
//whatever comment character conditional comment scripts use//-->
</SCRIPT>
<NOSCRIPT>
<P>I am sorry your browswer does not support conditional comments</p>
</NOSCRIPT>
</body>
Now the problems with conditional comments becomes all too clear.
1) Scripts as such are NOT defined in HTML 3.2 so we had to kick the
document to HTML 4.01 to use the script element.
<
http://www.w3.org/TR/REC-html32.html#script>
2) As per the warning on 18.3.2 some browsers may close the comment too
early. The ending ">"s need to be commented out per the spec.
3) Doing the script this way shows another problem. Under HTML 4.01 a '<'
is NOT supposed to be used WITHIN a script as this can cause all sorts of
problems.
Hence it is obvious that testing on various browsers is necessary.
Hence writing to ALL of HTML 4.01 specs rather than to the OBSOLETE HTML
3.2 specs and using broswer specific garbage (ie conditional comments) used
under HTML 3.2 is necessary.
In fact conditional comments are NONSTANDARD garbage under HMTL 3.2 because
scripts and script like behavior are not defined and were slated for a
FUTURE version of HTML. Since scripts are not defined in HTML 3.2
conditional comments will validate them but that does NOT mean the pages is
truely following the HTML 3.2 spec. Any HTML page that uses scripts in ANY
form must used HTML 4.01 and those guidelines show the flaws with
conditional comments.
Finally conclusion. Validate the HTML but also check the spec to make sure
you are not exploiting a loophole in the validaters (which conditional
comments do.)