Document Object Model CSS Chris Wilson Microsoft Corp. Philippe Le Hégaret W3C Vidur Apparao Netscape Communications Corp. Overview of the DOM Level 2 CSS Interfaces

The DOM Level 2 Cascading Style Sheets (CSS) interfaces are designed with the goal of exposing CSS constructs to object model consumers. Cascading Style Sheets is a declarative syntax for defining presentation rules, properties and ancillary constructs used to format and render Web documents. This document specifies a mechanism to programmatically access and modify the rich style and presentation control provided by CSS (specifically CSS level 2 ). This augments CSS by providing a mechanism to dynamically control the inclusion and exclusion of individual style sheets, as well as manipulate CSS rules and properties.

The CSS interfaces are organized in a logical, rather than physical structure. A collection of all style sheets referenced by or embedded in the document is accessible on the document interface. Each item in this collection exposes the properties common to all style sheets referenced or embedded in HTML and XML documents; this interface is described in the . User style sheets are not accessible through this collection, in part due to potential privacy concerns (and certainly read-write issues).

For each CSS style sheet, an additional interface is exposed - the CSSStyleSheet interface. This interface allows access to the collection of rules within a CSS style sheet and methods to modify that collection. Interfaces are provided for each specific type of rule in CSS2 (e.g. style declarations, @import rules, or @font-face rules), as well as a shared generic CSSRule interface.

The most common type of rule is a style declaration. The CSSStyleRule interface that represents this type of rule provides string access to the CSS selector of the rule, and access to the property declarations through the CSSStyleDeclaration interface.

Finally, an optional CSS2Properties interface is described; this interface (if implemented) provides shortcuts to the string values of all the properties in CSS level 2.

All CSS objects in the DOM are "live", that is, a change in the style sheet is reflected in the computed and actual style.

CSS Fundamental Interfaces

The interfaces within this section are considered fundamental CSS interfaces, and must be supported by all conforming implementations of the CSS module. These interfaces represent CSS style sheets specifically.

A DOM application may use the hasFeature(feature, version) method of the DOMImplementation interface with parameter values "CSS" 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 Level 2 Core specification and the "Views" feature defined in the DOM Level 2 Views specification . Please refer to additional information about conformance in the DOM Level 2 Core specification .

&css-cssstylesheet; &css-cssrulelist; &css-cssrule; &css-cssstylerule; &css-cssmediarule; &css-cssfontfacerule; &css-csspagerule; &css-cssimportrule; &css-csscharsetrule; &css-cssunknownrule; &css-cssstyledeclaration; &css-cssvalue; &css-cssprimitivevalue; &css-cssvaluelist; &css-rgbcolor; &css-rect; &css-counter; Override and computed style sheet &css-viewcss; &css-documentcss; Style sheet creation &css-domimplementationcss; Element with CSS inline style &css-elementcssinlinestyle;
CSS2 Extended Interface

The interface found within this section are not mandatory. A DOM application may use the hasFeature(feature, version) method of the DOMImplementation interface with parameter values "CSS2" 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 "CSS" feature defined defined in . Please refer to additional information about conformance in the DOM Level 2 Core specification .

&css-css2properties;