Packagedom.style.css
Classpublic class CSSRule
InheritanceCSSRule Inheritance Object
Subclasses CSSCharsetRule, CSSFontFaceRule, CSSImportRule, CSSMediaRule, CSSPageRule, CSSStyleRule, CSSUnknownRule

Introduced in: DOM 2 Core 

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.

See also

MDC - CSSRule
W3C - DOM Level 2 Style: CSSRule


Public Properties
 PropertyDefined By
  DOM 2 Style cssText : DOMString
[read-only] The parsable textual representation of the rule.
CSSRule
  DOM 2 Style parentRule : CSSRule
[read-only] If this rule is contained inside another rule (e.g.
CSSRule
  DOM 2 Style parentStyleSheet : CSSStyleSheet
[read-only] The style sheet that contains this rule.
CSSRule
  DOM 2 Style type : Number
[read-only] The type of the rule, as defined above.
CSSRule
Public Constants
 ConstantDefined By
  DOM 2 Style CHARSET_RULE : Number = 2
The rule is a CSSCharsetRule.
CSSRule
  DOM 2 Style FONT_FACE_RULE : Number = 5
The rule is a CSSFontFaceRule.
CSSRule
  DOM 2 Style IMPORT_RULE : Number = 3
The rule is a CSSImportRule.
CSSRule
  DOM 2 Style MEDIA_RULE : Number = 4
The rule is a CSSMediaRule.
CSSRule
  DOM 2 Style PAGE_RULE : Number = 6
The rule is a CSSPageRule.
CSSRule
  DOM 2 Style STYLE_RULE : Number = 1
The rule is a CSSStyleRule.
CSSRule
  DOM 2 Style UNKNOWN_RULE : Number = 0
The rule is a CSSUnknownRule.
CSSRule
Property Detail
DOM 2 Style cssTextproperty
cssText:DOMString  [read-only]

Introduced in: DOM 2 Core 

The parsable textual representation of the rule. This reflects the current state of the rule and not its initial value.


Implementation
    public function get cssText():DOMString

Throws
DOMException — SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
 
DOMException — INVALID_MODIFICATION_ERR: Raised if the specified CSS string value represents a different type of rule than the current one.
 
DOMException — HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at this point in the style sheet.
 
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised if the rule is readonly.

See also


Example
         if ( myRule.cssText.indexOf("background-color") != -1 ) {
             bgRule = myRule;
         } 
DOM 2 Style parentRuleproperty 
parentRule:CSSRule  [read-only]

Introduced in: DOM 2 Core 

If this rule is contained inside another rule (e.g. a style rule inside an @media block), this is the containing rule. If this rule is not nested inside any other rules, this returns null.


Implementation
    public function get parentRule():CSSRule

See also

DOM 2 Style parentStyleSheetproperty 
parentStyleSheet:CSSStyleSheet  [read-only]

Introduced in: DOM 2 Core 

The style sheet that contains this rule.


Implementation
    public function get parentStyleSheet():CSSStyleSheet

See also


Example
         if ( bgRule.parentStyleSheet != mySheet ) {
             // alien style rule!
         }
DOM 2 Style typeproperty 
type:Number  [read-only]

Introduced in: DOM 2 Core 

The type of the rule, as defined above.

The expectation is that binding-specific casting methods can be used to cast down from an instance of the CSSRule interface to the specific derived interface implied by the type.


Implementation
    public function get type():Number

See also

Constant Detail
DOM 2 Style CHARSET_RULEConstant
public const CHARSET_RULE:Number = 2

Introduced in: DOM 2 Core 

The rule is a CSSCharsetRule.

See also

DOM 2 Style FONT_FACE_RULEConstant 
public const FONT_FACE_RULE:Number = 5

Introduced in: DOM 2 Core 

The rule is a CSSFontFaceRule.

See also

DOM 2 Style IMPORT_RULEConstant 
public const IMPORT_RULE:Number = 3

Introduced in: DOM 2 Core 

The rule is a CSSImportRule.

See also

DOM 2 Style MEDIA_RULEConstant 
public const MEDIA_RULE:Number = 4

Introduced in: DOM 2 Core 

The rule is a CSSMediaRule.

See also

DOM 2 Style PAGE_RULEConstant 
public const PAGE_RULE:Number = 6

Introduced in: DOM 2 Core 

The rule is a CSSPageRule.

See also

DOM 2 Style STYLE_RULEConstant 
public const STYLE_RULE:Number = 1

Introduced in: DOM 2 Core 

The rule is a CSSStyleRule.

See also

DOM 2 Style UNKNOWN_RULEConstant 
public const UNKNOWN_RULE:Number = 0

Introduced in: DOM 2 Core 

The rule is a CSSUnknownRule.

See also