The HTML validator I found today – http://html5.validator.nu/ – says that my use of the <noscript> element is wrong. My XHTML source code is like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
<body>
<div id="head">
<noscript>
<p>JavaScript is disabled.</p>
</noscript>
...
The error message from the validator is this:
Error: XHTML element noscript not allowed as child of XHTML element div in this context. (Suppressing further errors from this subtree.)
Contexts in which element noscript may be used:
- In a head element of an HTML document, if there are no ancestor noscript elements.
- Where phrasing content is expected in HTML documents, if there are no ancestor noscript elements.
Content model for element div:
- Flow content.
Now I went on to the Mozilla Documentation and tried to understand what that means. I have found some information about content categories, flow content, phrasing content, what elements belong to each category (whatever "belong" means exactly) and how the <noscript> element may be used. (https://developer.mozilla.org/en/HTML/Element/noscript)
I now know this: <div> must contain flow content. <noscript> must occur in phrasing content. That obviously doesn’t match. How can I manage that? Many elements are in both, flow and phrasing, categories though. They don’t seem to be disjunct sets, so some can’t decide or I don’t get it.
How does the HTML specification intend to solve this quirks?
You shouldn’t use an HTML5 validator to validate your XHTML 1.1 document.
The HTML5 spec says about the
noscriptelement:So
noscriptinsidedivisn’t allowed in XHTML5, but it’s allowed in XHTML 1.1.