noscript ElementThe noscript element is declared by the XHTML 1.1 Scripting Module
Elements in the Scripting Module are:script | noscript
The noscript element is used to contain content
which should be rendered only by those user agents which do not support
an included script. Quoting from the
*HTML 4.01 NOSCRIPT element
specifications, the content of the noscript element should only be rendered if:
- The user agent is configured not to evaluate scripts.
- The user agent doesn't support a scripting language invoked by a SCRIPT element earlier in the document.
This seems quite imprecise to me and, personally, I would find the noscript element
much more useful if it had a type attribute to say explicitly for which scripting type that noscript
element is to be associated - and also, as an alternative, a for attribute to link that noscript to a particular script
element, via its id attribute. Sadly, this is not the case and I find that the noscript element is therefore quite limited in its usefulness.
In fact, ever since I noticed a bug in a fairly recent version of Opera, where the noscript content was rendered
even with scripting enabled, I have stopped using noscript entirely. My solution, since I tend to code
JavaScript only for those user agents which are compatible with the DOM,
is that I instead place any non-scripting content inside a div and subsequently remove that div from the
DOM in the JavaScript itself - using div.parentNode.removeChild( div ). (Some may think that
merely setting the CSS style
of the div to be display:none in the JavaScript
would suffice, but it is not uncommon for users to have scripting enabled but author styles disabled, in which case both the
scripting and non-scripting content would be visible.)
There is an added benefit to using the scripting code itself to remove any noscript warnings: this allows such content to be removed only if the script executes successfully, leaving the warning visible to those user agents which support the scripting language but fail to execute the script due to compatibility issues.
Note: The noscript element may have only block-level elements as children. It is therefore a puzzle to me that the XHTML DTD
allows noscript to occur in places where block-level elements are forbidden (within a p or span element, for example). Although
this site follows the current behaviour of the *W3C Validator in allowing such nesting, I
would nevertheless advise against it.
Update: If you want compatibility between XML-based and HTML-based user agents, the
noscript element should not be used at all. Ref: W3C Note (work in progress)
*XHTML Media Types - Compatibility Guidelines - Item A.25.
There are no #REQUIRED attributes on the noscript element.
There are no specific attributes declared on the noscript element.
noscript element are listed below:class [ type NMTOKENS ]id [ type ID ]style [ type CDATA ], from the Style Attribute Module (deprecated)title [ type Text ]xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Modulexml:lang [ type LanguageCode ]All attributes in the
Events Attribute Collection
are supported:onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
noscript element is:
NOTE: This element cannot be empty
See Content Model & Nesting for information about Content Model syntax and Nesting Groups.
noscriptaddress, blockquote, div, h1 - h6, p, predl, ol, ultablefieldset, formhrnoscript, scriptdel, insnoscriptbodyabbr, acronym, address, blockquote, cite, code, dfn, div, em, h1 - h6, kbd, p, q, samp, span, strong, varadd, dt, licaption, td, thbutton, fieldset, form, label, legendb, big, i, small, sub, sup, ttmapnoscriptdel, insbdoobjectrb, rt