Document Object Model Style Sheets Chris Wilson Microsoft Corp. Philippe Le Hégaret W3C Vidur Apparao Netscape Communications Corp. Introduction

The DOM Level 2 Style Sheet interfaces are base interfaces used to represent any type of style sheet. The expectation is that DOM modules that represent a specific style sheet language may contain interfaces that derive from these interfaces.

The interfaces found within this section are not mandatory. A DOM application may use the hasFeature(feature, version) method of the DOMImplementation interface with parameter values "StyleSheets" and "2.0" (respectively) to determine whether or not this module is supported by the implementation. In order to fully support this module, an implementation must also support the "Core" feature defined defined in the DOM 2 Core specification . Please refer to additional information about conformance in the DOM Level 2 Core specification .

Style Sheet Interfaces

This set of interfaces represents the generic notion of style sheets.

&stylesheets-stylesheet; &stylesheets-stylesheetlist; &stylesheets-medialist;
Document Extensions &stylesheets-linkstyle; &stylesheets-documentstyle; Association between a style sheet and a document.

A style sheet can be associated with an HTMLDocument in one of two ways:

By creating a new LINK HTML element (see the HTMLLinkElement interface in the and ). The underlying style sheet will be created after the element is inserted into the document and both the href and the type attribute have been set in a way indicating that the linked object is a style sheet.

By creating a new STYLE HTML element (see the HTMLStyleElement interface in the and ). The underlying style sheet will be created after the element is inserted into the document and the type attribute is set in a way indicating that the element corresponds to a style sheet language interpreted by the user agent.

Removing a LINK HTML element or a STYLE HTML element removes the underlying style sheet from the style sheet collection associated with a document. Specifically, the removed style sheet is no longer applied to the presentation of the document.

A new style sheet can be created and associated with an XML document by creating a processing instruction with the target 'xml-stylesheet' and inserting it into the document.

Removing a processing instruction with a target of 'xml-stylesheet' removes the underlying style sheet from the style sheet collection associated with a document. Specifically, the removed style sheet is no longer applied to the presentation of the document.