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

Validator parses HTML in CSS block comment?

From: Russell Morrisey <Russell.Morrisey@missionse.com>
Date: Mon, 15 Aug 2011 16:10:29 -0400
To: "www-validator@w3.org" <www-validator@w3.org>
Message-ID: <E0AF9A556F4DAD4385952C1CC5276B243AF2A029A4@AEGISV-SLB31.njmrsnet-aegis.com>
Do elements within a <style> tag, inside a /* block comment */, need to be HTML entity-escaped? This seems counter-intuitive, and burdensome; but, it's possible that I'm just confused.

When I run the HTML snippet given below through the validator, I get the following validation error:
document type does not allow element X here

The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).

    *   Line 11, column 32: document type does not allow element "div" here

   Usage:  <div class="pageTitle">This is the Page Title</div>

Is this correct behavior for the validator? If so, what are the requirements for escaping text within these block comments?

The following HTML snippet reproduces the issue:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


                        <title>Sample Page</title>

                        <style type="text/css">


            Sets the font properties to create a consistent Page Title

            Usage:  <div class="pageTitle">This is the Page Title</div>









Software Engineer, Staff
Mission Solutions Engineering, LLC

| Russell.Morrisey@missionse.com | www.missionse.com<http://www.missionse.com/>
304 West Route 38, Moorestown, NJ 08057-3212

This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery.
NOTE: Regardless of content, this e-mail shall not operate to bind MSE to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose.
Received on Tuesday, 16 August 2011 12:39:14 UTC

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