Re: HTML4 + <script><![CDATA[ </ENDTAG> ]]></script>
Leif Halvard Silli <xn--mlform-iua <at> xn--mlform-iua.no>
2010-02-01 16:42:43 GMT
David Dorward, Mon, 1 Feb 2010 10:51:16 +0000:
> On 1 Feb 2010, at 10:03, Leif Halvard Silli wrote:
>> Or, why doesn't the compatibility guidelines mention that, for
>> embedding, then one should use BOTH "\/" and "<![CDATA[ ...]]>"
> Because they are concerned with writing XHTML that is compatible with
> HTML parsers, not writing code that is both valid XHTML and HTML
> (which is impossible once you start dealing with XHTML self-closing
> tag syntax in the <head>).
Well, the right hand should care a little bit about what the left hand
Why does the HTML4 validator care about theoretical SGML while the
XHTML guidelines care about real text/HTML parsers, only? They should
try to live up to the same standard/reality.
(It is sometimes said that having to wrap the script in <![CDATA[ ]]>
is a reason to use external scripts [e.g. you said so!]. This thing is
also been used as argument for saying that it is more difficult to
even more reason to place HTML4 scripts in external files, due the to
issue with the \/ escaping.)
>> interpreter - instead of recommending to not use HTML comments at all,
>> like the guidelines does/do, I would recommend this:
>> line beings with a "<!--" in order accept that the first line is a
>> comment. If the code also ends with a "-->", then it can as well be
>> interpreted as a valid HTML comment.
> ... or you could just use a JS comment rather than depending on hacks
> designed to avoid having Netscape 2 and friends render JS as text
> (which would break if the script was placed in an external file).
I believe all user agents support this so called hack - so I wonder why
it isn't upgraded from being considered hack. I suppose I will continue
to us <!--->, as may be compatible with a wider range of scripting
languages. (After all, most scripting languages for the web has some
knowledge about the HTML syntax.)
>> OK, thanks David. Much appreciated. It would really be helpful if the
>> HTML4 validator recommended escaping the "\/" instead of (only) telling
>> us to use external script files.
> It does.
The validator? Yes. In in cryptic words - as you documented below.
> • Line 6, Column 30: end tag for element "DIV" which is not open
[ snip ]
> If this error occurred in a script section of your document, you
> should probably read this FAQ entry.
Right. There is just a single, cryptic sentence about the entire issue.
>> From said FAQ entry:
> Authors should avoid using strings such as "</P>" in their embedded
> string from being parsed as markup:
> (Followed by an example)
You say that you quoted the FAQ. However, you did not quote the FAQ -
you quoted the WDG page which the FAQ points to. The FAQ only says this:
Most probably, you should read the script section of WDG's excellent
Common HTML Validation Problems document.
So the FAQ page is - or appears - so cocky that it cannot explain this
in its own words. The FAQ has a unnecessary gotcha attitude. The W3
validator did not need to point to the FAQ - it could have explained
this issue itself - and it could have pointed to HTML4 directly -
<http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.2.1>. Or at least
the FAQ could have done so. And the validator could also have mentioned
a word about the discrepancy between user agents and SGML requirements.
Btw, the WDG page is wrong when it says that "in XHTML, authors must
_also_ take care when using start tags within a script element".
Because, as we have discussed in this thread: in XHTML, as long as you
wrap the script in <![CDATA[ ]], then you do in principle not _also_
have to use "\/" - except, of course for compatibility with HTML4.
leif halvard silli