CSSStyleDeclaration : Object

CSS style declaration block consisting of CSS attributes and their values.

Browser/User Agent Support

IEMozillaNetscapeOperaSafariNetscapte
no1.0+no9.0+1.0+no

Constructors

ConstructorIEMozillaNetscapeOperaSafariNetscapte
CSS style declaration block consisting of CSS attributes and their values.
no1.0+no9.0+1.0+no
 

Properties

PropertyIEMozillaNetscapeOperaSafariNetscapte
Text for the current CSS rule.
no1.0+no9.0+1.0+no
 
Number of CSS style attributes in the style declaration block.
no1.0+no9.0+1.0+no
 
CSSRule that contains the CSSStyleDeclaration.
no1.0+no9.0+1.0+no
 

Methods

MethodIEMozillaNetscapeOperaSafariNetscapte
Returns a CSS attribute value as an object.
no1.0+nononono
 
Returns the priority of a CSS attribute.
no1.0+no9.0+1.0+no
 
Returns a CSS attribute value as a string.
no1.0+no9.0+1.0+no
 
Returns the name of the CSS attribute at the specified position.
no1.0+no9.0+1.0+no
 
Removes the specified CSS attribute from the CSS style declaration block.
no1.0+no9.0+1.0+no
 
Sets the value for a CSS attribute for a CSS style declaration block.
no1.0+no9.0+1.0+no
 

References

CSS2Properties

Availability

HTML DOM Level 2 | W3C

Constructor Detail

CSSStyleDeclaration CSSStyleDeclaration()

CSS style declaration block consisting of CSS attributes and their values.

Visibility
internal

Property Detail

String cssText

Text for the current CSS rule.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/stylesheets.html

Remarks

If you specify an invalid value for cssText, the property may throw one of the following DOMExceptions:

  • HIERARCHY_REQUEST_ERR - CSS rule is not legal in the current location in the CSS style sheet.
  • INVALID_MODIFICATION_ERR - New value for the CSS rule is for a different type than the previous type.
  • NO_MODIFICATION_ALLOWED_ERR - The CSS rule or its parent CSS style sheet is read-only.
  • SYNTAX_ERR - CSS syntax error.
Availability

HTML DOM Level 2 | W3C

Number length - read only

Number of CSS style attributes in the style declaration block.

Availability

HTML DOM Level 2 | W3C

CSSRule parentRule - read only

CSSRule that contains the CSSStyleDeclaration.

Availability

HTML DOM Level 2 | W3C

Method Detail

getPropertyCSSValue(String propertyName) : static CSSValue

Returns a CSS attribute value as an object.

StringpropertyNameName of the CSS attribute to return the CSS value for.

Availability

HTML DOM Level 2 | W3C

getPropertyPriority(String propertyName) : static String

Returns the priority of a CSS attribute.

StringpropertyNameName of the CSS attribute to return the priority value for.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/style.html

Availability

HTML DOM Level 2 | W3C

getPropertyValue(String propertyName) : static String

Returns a CSS attribute value as a string.

StringpropertyNameName of the CSS attribute to return the value for.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/style.html

Availability

HTML DOM Level 2 | W3C

item(Number index) : static String

Returns the name of the CSS attribute at the specified position.

NumberindexPosition of the CSS attribute to retrieve.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/item.html

Availability

HTML DOM Level 2 | W3C

removeProperty(String propertyName) : static String

Removes the specified CSS attribute from the CSS style declaration block.

StringpropertyNameName of the CSS attribute to delete.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/style.html

Availability

HTML DOM Level 2 | W3C

setProperty(String propertyName, String value, String priority) : void

Sets the value for a CSS attribute for a CSS style declaration block.

StringpropertyNameName of the CSS attribute to set.
StringvalueValue for the CSS attribute.
StringpriorityPriority for the CSS attribute. Specify either the string "important" or an empty string.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/style.html

Availability

HTML DOM Level 2 | W3C