noscript Element


 

Module

The noscript element is declared by the XHTML 1.1 Scripting Module

Elements in the Scripting Module are:
script | noscript

Description

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.

#REQUIRED Attributes

There are no #REQUIRED attributes on the noscript element.


Specific Attributes

There are no specific attributes declared on the noscript element.


Common Attributes

Common attributes of the noscript element are listed below:

From the Core Attribute Collection

class [ type NMTOKENS ]
One or more space separated classes
id [ type ID ]
A unique identifier for the element
style [ type CDATA ], from the Style Attribute Module (deprecated)
Element-specific styles
title [ type Text ]
Descriptive title for the element (in some user agents this may appear as a "tooltip" when the mouse hovers over the element)
xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]
XML namespace

From the I18N Attribute Collection

dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Module
Left-to-right or right-to-left directionality
xml:lang [ type LanguageCode ]
A language code for the element

From the Events Attribute Collection

All attributes in the Events Attribute Collection are supported:
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup


Content Model

The Content Model for the noscript element is:

Block.mix+

NOTE: This element cannot be empty

See Content Model & Nesting for information about Content Model syntax and Nesting Groups.

Valid children of noscript

Valid parents of noscript


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 01 Oct 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Indexes > Element Index (XHTML 1.1) > noscript Element