W3C home > Mailing lists > Public > www-html@w3.org > August 2000

Re: XHTML Invalidity / WML2 / New XHTML 1.1 Attribute

From: Stephanos Piperoglou <stephanos@webreference.com>
Date: Tue, 15 Aug 2000 16:34:22 +0100 (BST)
To: www-html@w3.org
Message-ID: <Pine.LNX.4.21.0008151622590.7047-100000@highnoon.pipis.net>
On Tue, 15 Aug 2000, Cavre wrote:

> Not sure I understand why this would be such a problem.  Older
> browsers ignore Javascript markup via <!-- {ok so that is more a
> hack than a actual implantation, but it does work} There must be
> something here that I must learn., but it seems to me that a parser
> would ignore any content not found outside of it's framework.

AFAIK it's not a hack - according to the HTML4 DTD [1]:

<!ELEMENT SCRIPT - - %Script; -- script statements -->
<!ENTITY % Script "CDATA" -- script expression -->

And:

<!ELEMENT STYLE - - %StyleSheet -- style info -->
<!ENTITY % StyleSheet "CDATA" -- style sheet data -->

I'm not an SGML expert but AFAIK the contents of both SCRIPT and STYLE
elements are CDATA (as opposed to PCDATA) which means they're not
parsed for much other that "</" (which is why "</" should never appear
in inline scripts and style sheets). Hence the entire contents of the
SCRIPT element are passed verbatim to the JavaScript (or whatever)
parser, which recognizes "<!--" and "-->" and throws them out. I.e.,
in HTML4-compliant browsers, the CDO and CDC delimiters are considered
either script data or style sheet data; Older browsers (which, in an
SGML-compliant world, would choke on HTML4 anyway, they just parse it
out of the goodness of their heart - or, as is more often the case,
because their parsers are pretty simple in design and would parse line
noise if they could) will consider them HTML and hence recognize them
as comments.

Once again, that's my understanding, but I don't know all that much
about HTML. Please correct me if I'm wrong.

[1] http://www.w3.org/TR/html4/sgml/dtd.html

-- 
Stephanos Piperoglou                              <stephanos@webreference.com>
Maintainer, HTML with Style                    <http://webreference.com/html/>
  Visit HTML with Style for online HTML and CSS tutorials with step-by-step
   procedures and practical examples to help you author Web pages that are
 full-featured, standards-compliant and backwards-compatible, tools to make a
 Web author's life easier, software reviews, opinions, industry news and more
Received on Tuesday, 15 August 2000 09:33:47 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:43 GMT