Export (0) Print
Expand All

2.2.4 [DOM Level 2 - Style] Section 2.2, Interface CSSStyleSheet (introduced in DOM Level 2)

V0009:

The specification states:

The CSSStyleSheet interface is a concrete interface used to represent a CSS style 
sheet i.e., a style sheet whose content type is "text/css".

IDL Definition
// Introduced in DOM Level 2:
interface CSSStyleSheet : stylesheets::StyleSheet {
  readonly attribute CSSRule          ownerRule;
  readonly attribute CSSRuleList      cssRules;
  unsigned long      insertRule(in DOMString rule, 
                                in unsigned long index)
                                        raises(DOMException);
  void               deleteRule(in unsigned long index)
                                        raises(DOMException);
};

Quirks Mode, IE7 Mode, and IE8 Mode (All Versions)

The following standard attributes or methods are not supported:

  • cssRules

  • ownerRule

  • insertRule

  • deleteRule

The following additional attributes or methods are supported:

  • readonly

  • id

  • imports

  • pages

  • rules

  • addImport

  • addPageRule

  • addRule

  • removeImport

  • removeRule

IE8 Mode (All Versions)

The additional attributes isAlternate and isPrefAlternate are supported.

V0010:

The specification states:

The CSSRule interface is the abstract base interface for any type of CSS statement. 
This includes both rule sets and at-rules. An implementation is expected to 
preserve all rules specified in a CSS style sheet, even if the rule is not 
recognized by the parser. Unrecognized rules are represented using the 
CSSUnknownRule interface."

IDL Definition
// Introduced in DOM Level 2:
interface CSSRule {

  // RuleType
  const unsigned short      UNKNOWN_RULE                   = 0;
  const unsigned short      STYLE_RULE                     = 1;
  const unsigned short      CHARSET_RULE                   = 2;
  const unsigned short      IMPORT_RULE                    = 3;
  const unsigned short      MEDIA_RULE                     = 4;
  const unsigned short      FONT_FACE_RULE                 = 5;
  const unsigned short      PAGE_RULE                      = 6;

  readonly attribute unsigned short   type;
           attribute DOMString        cssText;
                                        // raises(DOMException) on setting

  readonly attribute CSSStyleSheet    parentStyleSheet;
  readonly attribute CSSRule          parentRule;
};

Quirks Mode, IE7 Mode, and IE8 Mode (All Versions)

The following variations apply:

  • The CSSRule interface is not supported.

  • The rule object can be used to represent a style within a style sheet that consists of a selector and one or more declarations.

  • The page object represents an @page rule within a styleSheet object.

  • The imports object represents an @import rule within a styleSheet object.

IE9 Mode, IE10 Mode, and IE11 Mode (All Versions)

The CSSRule interface is supported, but the UNKNOWN_RULE and CHARSET_RULE rule types are not supported.

Setting the cssText attribute does not raise a DOMException exception. The command to set the cssText attribute is ignored.

V0011:

The specification states:

The CSSStyleRule interface represents a single rule set in a CSS style sheet.

IDL Definition
// Introduced in DOM Level 2:
interface CSSStyleRule : CSSRule {
           attribute DOMString        selectorText;
                                        // raises(DOMException) on setting

  readonly attribute CSSStyleDeclaration  style;
};

Quirks Mode, IE7 Mode, and IE8 Mode (All Versions)

The following variations apply:

  • The CSSStyleRule interface does not support the inherited properties of the CSSRule interface.

  • The readOnly property is an additional supported property.

  • The selectorText property is read-only.

IE9 Mode, IE10 Mode, and IE11 Mode (All Versions)

Setting selectorText does not raise a DOMException. The command is ignored.

V0012:

The specification states:

The CSSMediaRule interface represents a @media rule in a CSS style sheet. A @media 
rule can be used to delimit style rules for specific media types.

IDL Definition
// Introduced in DOM Level 2:
interface CSSMediaRule : CSSRule {
  readonly attribute stylesheets::MediaList  media;
  readonly attribute CSSRuleList      cssRules;
  unsigned long      insertRule(in DOMString rule, 
                                in unsigned long index)
                                        raises(DOMException);
  void               deleteRule(in unsigned long index)
                                        raises(DOMException);
};

Quirks Mode, IE7 Mode, and IE8 Mode (All Versions)

The CSSMediaRule interface is not supported.

V0013:

The specification states:

The CSSFontFaceRule interface represents a @font-face rule in a CSS style sheet. 
The @font-face rule is used to hold a set of font descriptions.

IDL Definition
// Introduced in DOM Level 2:
interface CSSFontFaceRule : CSSRule {
  readonly attribute CSSStyleDeclaration  style;
};

Quirks Mode, IE7 Mode, and IE8 Mode (All Versions)

The CSSFontFaceRule interface is not supported.

V0014:

The specification states:

The CSSPageRule interface represents a @page rule within a CSS style sheet. The 
@page rule is used to specify the dimensions, orientation, margins, etc. of a page 
box for paged media.

Quirks Mode, IE7 Mode, and IE8 Mode (All Versions)

The CSSPageRule interface is not supported.

The page object represents an @page rule within a style sheet.

V0015:

The specification states:

The CSSImportRule interface represents a @import rule within a CSS style sheet. The 
@import rule is used to import style rules from other style sheets.

Quirks Mode, IE7 Mode, and IE8 Mode (All Versions)

The CSSImportRule interface is not supported.

The imports collection represents an @import rule within a style sheet.

V0016:

The specification states:

The CSSCharsetRule interface represents a @charset rule in a CSS style sheet. The 
value of the encoding attribute does not affect the encoding of text data in the 
DOM objects; this encoding is always UTF-16. After a stylesheet is loaded, the 
value of the encoding attribute is the value found in the @charset rule. If there 
was no @charset in the original document, then no CSSCharsetRule is created. The 
value of the encoding attribute may also be used as a hint for the encoding used on 
serialization of the style sheet.
The value of the @charset rule (and therefore of the CSSCharsetRule) may not 
correspond to the encoding the document actually came in; character encoding 
information e.g. in an HTTP header, has priority (see CSS document representation) 
but this is not reflected in the CSSCharsetRule.

All Document Modes (All Versions)

The CSSCharsetRule interface is not supported.

V0017:

The specification states:

The CSSUnknownRule interface represents an at-rule not supported by this user agent.

All Document Modes (All Versions)

The CSSUnknownRule interface is not supported.

V0018:

The specification states:

The CSSStyleDeclaration interface represents a single CSS declaration block. This 
interface may be used to determine the style properties currently set in a block or 
to set style properties explicitly within the block. While an implementation may 
not recognize all CSS properties within a CSS declaration block, it is expected to 
provide access to all specified properties in the style sheet through the 
CSSStyleDeclaration interface. Furthermore, implementations that support a specific 
level of CSS should correctly handle CSS shorthand properties for that level.For a further discussion of shorthand properties, see the CSS2Properties interface.
This interface is also used to provide a read-only access to the computed values of an element. See also the ViewCSS interface.
Note: The CSS Object Model doesn't provide an access to the specified or actual values of the CSS cascade.
 
IDL Definition 
// Introduced in DOM Level 2:
interface CSSStyleDeclaration {
           attribute DOMString        cssText;
                                        // raises(DOMException) on setting

  DOMString          getPropertyValue(in DOMString propertyName);
  CSSValue           getPropertyCSSValue(in DOMString propertyName);
  DOMString          removeProperty(in DOMString propertyName)
                                        raises(DOMException);
  DOMString          getPropertyPriority(in DOMString propertyName);
  void               setProperty(in DOMString propertyName, 
                                 in DOMString value, 
                                 in DOMString priority)
                                        raises(DOMException);
  readonly attribute unsigned long    length;
  DOMString          item(in unsigned long index);
  readonly attribute CSSRule          parentRule;
};

Quirks Mode, IE7 Mode, and IE8 Mode (All Versions)

The cssText attribute is the only attribute supported in the CSSStyleDeclaration interface.

IE9 Mode, IE10 Mode, and IE11 Mode (All Versions)

The getPropertyPriority method returns an empty string for the following shorthand properties even if they have a priority (for example, "important"):

  • border-color

  • border-style

  • border-top

  • border-right

  • border-bottom

  • border-left

  • border-width

  • font

  • list-style

  • margin

  • outline

  • padding

The getPropertyCSSValue method is not supported.

V0019:

The specification states:

The CSSValue interface represents a simple or a complex value. A CSSValue object 
only occurs in a context of a CSS property.

All Document Modes (All Versions)

The CSSValue interface is not supported.

V0020:

The specification states:

The CSSPrimitiveValue interface represents a single CSS value. This interface may 
be used to determine the value of a specific style property currently set in a 
block or to set a specific style property explicitly within the block.

All Document Modes (All Versions)

The CSSPrimitiveValue interface is not supported.

V0021:

The specification states:

The CSSValueList interface provides the abstraction of an ordered collection of CSS values.

All Document Modes (All Versions)

The CSSValueList interface is not supported.

V0022:

The specification states:

The RGBColor interface is used to represent any RGB color value. This interface 
reflects the values in the underlying style property.

All Document Modes (All Versions)

The RGBColor interface is not supported.

V0023:

The specification states:

The Rect interface is used to represent any rect value. This interface reflects the 
values in the underlying style property.

All Document Modes (All Versions)

The Rect interface is not supported.

V0024:

The specification states:

The Counter interface is used to represent any counter or counters function value. 
This interface reflects the values in the underlying style property.

All Document Modes (All Versions)

The Counter interface is not supported.

Show:
© 2014 Microsoft