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?
The <noscript> tag in HTML is used to display the text for those browsers which does not support script tag or the browsers disable the script by the user. This tag is used in both <head> and <body> tag. Note: This tag is used in those browsers only which does not support scripts.
<noscript>: The Noscript element The <noscript> HTML element defines a section of HTML to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser. Metadata content, flow content, phrasing content.
Yes! You can definitely do that.
In HTML5 the <noscript> tag can be placed in the <head> and <body> elements. In HTML4 it can be used only in the <body> element.
You shouldn’t use an HTML5 validator to validate your XHTML 1.1 document.
The HTML5 spec says about the noscript
element:
The
noscript
element must not be used in XML documents.
So noscript
inside div
isn’t allowed in XHTML5, but it’s allowed in XHTML 1.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With