W3C home > Mailing lists > Public > www-validator@w3.org > August 2011

Re: Validator parses HTML in CSS block comment?

From: Leif Halvard Silli <xn--mlform-iua@xn--mlform-iua.no>
Date: Tue, 16 Aug 2011 21:28:00 +0200
To: www-validator@w3.org
Cc: Russell Morrisey <Russell.Morrisey@missionse.com>
Message-ID: <20110816212800273563.1f6e58bb@xn--mlform-iua.no>
Andreas Prilop, Tue, 16 Aug 2011 20:10:28 +0200 (CEST):
> On Mon, 15 Aug 2011, Russell Morrisey wrote:
>> Do elements within a <style> tag, inside a /* block comment */,
>> need to be HTML entity-escaped?
>   ...
>> The following HTML snippet reproduces the issue:
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> You don't use HTML, you use XHTML.
> But you do not understand the difference.
>  http://www.w3.org/TR/xhtml1/#h-4.8
> Stick to HTML 4 as long as you don't understand XHTML.

Ahem ... Please advice people to use HTML5, as you obviously don't 
understand HTML4 ... ;-) 

Because: According to HTML4, <style> is subject to the same parsing 
rules as the <script> elemeent. Wwhich means that the first occurrence 
of an end tag ought to cause the element to end, even if the end tag 
does not have the name "</style>". So, according to HTML4, Russel's 
"</div>" cannot occur inside the style element.

But, to answer Russel's question, this behaviour is not correct, as no 
Web browser behave that way. Hence, HTML5 has changed the rules to be 
more in line with how browsers actually act: In the HTML serialization 
of HTMl5, the "</div>" *is* permitted. (In the XML serialization - also 
known as XHTML - it remains forbidden.)

Further more, if Russel simply just replaces the XHTML doctype with the 
HTML5 doctype, the file will validate as is, with the xmlns namespace 
and everything. (The xmlns namespace validates only because HTML5' 
generous permission - and not because it plays any role.)
Leif H Silli
Received on Tuesday, 16 August 2011 19:28:44 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 14:18:04 UTC