Validator parses HTML in CSS block comment?

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"

            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



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

            <head>

                        <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>

*/

</style>

</head>

            <body>



            </body>

</html>



Thanks,

________________________________

RUSSELL E. MORRISEY
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