Packagedom.style.css
Classpublic class CSSStyleDeclaration
InheritanceCSSStyleDeclaration Inheritance Object

Introduced in: DOM 2 Core 

The CSSStyleDeclaration interface represents a single CSS declaration block.

TODO: Add MS proprietary methods

See also

MSDN - CSSStyleDeclaration
MDC - CSSStyleDeclaration
W3C - DOM Level 2 Style: CSSStyleDeclaration


Public Properties
 PropertyDefined By
  DOM 2 Style cssText : DOMString
[read-only] The parsable textual representation of the declaration block (excluding the surrounding curly braces).
CSSStyleDeclaration
  DOM 2 Style length : Number
[read-only] The number of properties that have been explicitly set in this declaration block.
CSSStyleDeclaration
  DOM 2 Style parentRule : CSSRule
[read-only] The CSS rule that contains this declaration block or null if this CSSStyleDeclaration is not attached to a CSSRule.
CSSStyleDeclaration
Public Methods
 MethodDefined By
  
DOM 2 Style getPropertyCSSValue(propertyName:DOMString):CSSValue
Used to retrieve the object representation of the value of a CSS property if it has been explicitly set within this declaration block.
CSSStyleDeclaration
  
DOM 2 Style getPropertyPriority(propertyName:DOMString):DOMString
Used to retrieve the priority of a CSS property (e.g.
CSSStyleDeclaration
  
DOM 2 Style getPropertyValue(propertyName:DOMString):DOMString
Used to retrieve the value of a CSS property if it has been explicitly set within this declaration block.
CSSStyleDeclaration
  
DOM 2 Style item(index:Number):DOMString
Used to retrieve the properties that have been explicitly set in this declaration block.
CSSStyleDeclaration
  
DOM 2 Style removeProperty(propertyName:DOMString):DOMString
Used to remove a CSS property if it has been explicitly set within this declaration block.
CSSStyleDeclaration
  
DOM 2 Style setProperty(propertyName:DOMString, value:DOMString, priority:DOMString):void
Used to set a property value and priority within this declaration block.
CSSStyleDeclaration
Property Detail
DOM 2 Style cssTextproperty
cssText:DOMString  [read-only]

Introduced in: DOM 2 Core 

The parsable textual representation of the declaration block (excluding the surrounding curly braces).

Setting this attribute will result in the parsing of the new value and resetting of all the properties in the declaration block including the removal or addition of properties.


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 — NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly or a property is readonly.

See also

DOM 2 Style lengthproperty 
length:Number  [read-only]

Introduced in: DOM 2 Core 

The number of properties that have been explicitly set in this declaration block. The range of valid indices is 0 to length-1 inclusive.


Implementation
    public function get length():Number

See also

DOM 2 Style parentRuleproperty 
parentRule:CSSRule  [read-only]

Introduced in: DOM 2 Core 

The CSS rule that contains this declaration block or null if this CSSStyleDeclaration is not attached to a CSSRule.


Implementation
    public function get parentRule():CSSRule

See also

Method Detail
DOM 2 Style getPropertyCSSValue()method
public function getPropertyCSSValue(propertyName:DOMString):CSSValue

Introduced in: DOM 2 Core 

Used to retrieve the object representation of the value of a CSS property if it has been explicitly set within this declaration block. This method returns null if the property is a shorthand property. Shorthand property values can only be accessed and modified as strings, using the getPropertyValue and setProperty methods.

Parameters

propertyName:DOMString — The name of the CSS property.

Returns
CSSValue — Returns the value of the property if it has been explicitly set for this declaration block. Returns null if the property has not been set.

See also

DOM 2 Style getPropertyPriority()method 
public function getPropertyPriority(propertyName:DOMString):DOMString

Introduced in: DOM 2 Core 

Used to retrieve the priority of a CSS property (e.g. the "important" qualifier) if the property has been explicitly set in this declaration block.

Parameters

propertyName:DOMString — The name of the CSS property.

Returns
DOMString — A string representing the priority (e.g. "important") if one exists. The empty string if none exists.

See also

DOM 2 Style getPropertyValue()method 
public function getPropertyValue(propertyName:DOMString):DOMString

Introduced in: DOM 2 Core 

Used to retrieve the value of a CSS property if it has been explicitly set within this declaration block.

Parameters

propertyName:DOMString — The name of the CSS property.

Returns
DOMString — Returns the value of the property if it has been explicitly set for this declaration block. Returns the empty string if the property has not been set.

See also

DOM 2 Style item()method 
public function item(index:Number):DOMString

Introduced in: DOM 2 Core 

Used to retrieve the properties that have been explicitly set in this declaration block. The order of the properties retrieved using this method does not have to be the order in which they were set. This method can be used to iterate over all properties in this declaration block.

Parameters

index:Number — Index of the property name to retrieve.

Returns
DOMString — The name of the property at this ordinal position. The empty string if no property exists at this position.

See also

DOM 2 Style removeProperty()method 
public function removeProperty(propertyName:DOMString):DOMString

Introduced in: DOM 2 Core 

Used to remove a CSS property if it has been explicitly set within this declaration block.

Parameters

propertyName:DOMString — The name of the CSS property.

Returns
DOMString — Returns the value of the property if it has been explicitly set for this declaration block. Returns the empty string if the property has not been set or the property name does not correspond to a known CSS property.

Throws
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly or the property is readonly.

See also

DOM 2 Style setProperty()method 
public function setProperty(propertyName:DOMString, value:DOMString, priority:DOMString):void

Introduced in: DOM 2 Core 

Used to set a property value and priority within this declaration block.

Parameters

propertyName:DOMString — The name of the CSS property.
 
value:DOMString — The new value of the property.
 
priority:DOMString — The new priority of the property (e.g. "important").


Throws
DOMException — SYNTAX_ERR: Raised if the specified value has a syntax error and is unparsable.
 
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly or the property is readonly.

See also