W3C home > Mailing lists > Public > www-validator@w3.org > May 2008

Re: HTML Comment In Script Elements

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Mon, 12 May 2008 08:51:05 +0300
Message-ID: <003801c8b3f4$2bfd93d0$0500000a@DOCENDO>
To: "Kravvitz" <Kravvitz.css-validator@dynamicsitesolutions.com>, <www-validator@w3.org>

Kravvitz wrote:

> Is it intentional that the HTML Validator doesn't give an error
> message when an HTML comment is started in a <script> element but the
> end of it is missing in an HTML document?

There are no HTML comments inside a <script> element, since the content 
model is CDATA, which means that no markup is recognized, except for end 
tags. Thus, from the viewpoint of HTML syntax, "<!--" inside a <script> 
element is just character data.

> It does show error messages
> as a result of this error in XHTML documents.

In XHTML, the content model is #PCDATA, which means that markup is 

In practice, "<!--" inside a <script> element is risky in XHTML 
documents, since when the document is processed genuinely as XHTML, the 
browser or other processor _may_ remove comments before any other 
processing, but is not required to. And when processed as classic HTML, 
which is the only way to make XHTML digestible to IE, such "comments" 
are not removed but passed to the script language processor.

Jukka K. Korpela ("Yucca")
Received on Monday, 12 May 2008 05:51:30 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:59:08 UTC