Object: CSSStyleDeclaration
The CSSStyleDeclaration object represents a CSS declaration block consisting of CSS properties and their values. This object enables you to determine the style properties currently set in a block or to set style properties explicitly within the block.
This object also provides access to the computed values of an element. It does not provide access to the specified or actual values of the CSS cascade.
CSSStyleDeclaration properties
Property name |
Type |
Description |
Status |
Availability |
|---|---|---|---|---|
azimuth |
String |
Specifies the direction from which a sound originates. |
writable |
4.6 or later |
background |
String |
Specifies any or all background properties. |
writable |
4.6 or later |
backgroundAttachment |
String |
Specifies whether the background scrolls with the page. |
writable |
4.6 or later |
backgroundColor |
String |
Specifies the background color for an element. |
writable |
4.6 or later |
backgroundImage |
String |
Specifies an image resource to use as the background. |
writable |
4.6 or later |
backgroundPosition |
String |
Specifies the starting position of a background image. |
writable |
4.6 or later |
backgroundRepeat |
String |
Specifies how or if a background image is repeated. |
writable |
4.6 or later |
border |
String |
Specifies any or all border properties for an element. |
writable |
4.6 or later |
borderBottom |
String |
Specifies any or all bottom border properties for an element. |
writable |
4.6 or later |
borderBottomColor |
String |
Specifies the bottom border color for an element |
writable |
4.6 or later |
borderBottomStyle |
String |
Specifies the bottom border style for an element. |
writable |
4.6 or later |
borderBottomWidth |
String |
Specifies the bottom border width of an element. |
writable |
4.6 or later |
borderCollapse |
String |
Specifies whether the table borders are collapsed into a single border. |
writable |
4.6 or later |
borderColor |
String |
Specifies the border color for an element. |
writable |
4.6 or later |
borderLeft |
String |
Specifies any or all left border properties for an element. |
writable |
4.6 or later |
borderLeftColor |
String |
Specifies the left border color for an element. |
writable |
4.6 or later |
borderLeftStyle |
String |
Specifies the left border style for an element. |
writable |
4.6 or later |
borderLeftWidth |
String |
Specifies the left border width of an element. |
writable |
4.6 or later |
borderRight |
String |
Specifies any or all right border properties for an element. |
writable |
4.6 or later |
borderRightColor |
String |
Specifies the right border color for an element. |
writable |
4.6 or later |
borderRightStyle |
String |
Specifies the right border style for an element. |
writable |
4.6 or later |
borderRightWidth |
String |
Specifies the right border width of an element. |
writable |
4.6 or later |
borderSpacing |
String |
Specifies the distance between the cell borders when not collapsed. |
writable |
4.6 or later |
borderStyle |
String |
Specifies the border style for an element. |
writable |
4.6 or later |
borderTop |
String |
Specifies any or all top border properties for an element. |
writable |
4.6 or later |
borderTopColor |
String |
Specifies the top border color for an element. |
writable |
4.6 or later |
borderTopStyle |
String |
Specifies the top border style for an element. |
writable |
4.6 or later |
|
borderTopWidth |
String |
Specifies the top border width of an element. |
writable |
4.6 or later |
borderWidth |
String |
Specifies the border width of an element. |
writable |
4.6 or later |
bottom |
String |
Specifies the distance of the bottom edge of an element above or below the parent element. |
writable |
4.6 or later |
captionSide |
String |
Specifies the location of the table caption. |
writable |
4.6 or later |
clear |
String |
Specifies the side(s) of an element that may not be adjacent to floating elements. |
writable |
4.6 or later |
clip |
String |
Specifies the shape of the element. |
writable |
4.6 or later |
color |
String |
Specifies the foreground color for an element. |
writable |
4.6 or later |
content |
String |
Used with the :before and :after pseudo-elements to generate content. |
writable |
4.6 or later |
counterIncrement |
String |
Specifies how much the counter is incremented for every occurrence of the element. |
writable |
4.6 or later |
counterReset |
String |
Resets a counter for an element. |
writable |
4.6 or later |
cue |
String |
Specifies any or all cue properties. |
writable |
4.6 or later |
cueAfter |
String |
Specifies a URI containing a sound that is played after an element. |
writable |
4.6 or later |
cueBefore |
String |
Specifies a URI containing a sound that is played before an element. |
writable |
4.6 or later |
cursor |
String |
Specifies the type of cursor. |
writable |
4.6 or later |
direction |
String |
Specifies the base direction of the text. |
writable |
4.6 or later |
display |
String |
Specifies how or if an element is displayed. |
writable |
4.6 or later |
elevation |
String |
Specifies the elevation from which a sound originates. |
writable |
4.6 or later |
emptyCells |
String |
Specifies whether empty cells are displayed when the borders are not merged. |
writable |
4.6 or later |
CSSFloat |
String |
Specifies where an image or text will appear in another element. |
writable |
4.6 or later |
font |
String |
Specifies any or all of the font properties for an element. |
writable |
4.6 or later |
fontFamily |
String |
Specifies the font family for an element. |
writable |
4.6 or later |
fontSize |
String |
Specifies the font size for an element. |
writable |
4.6 or later |
fontStyle |
String |
Specifies the style of the font for an element. |
writable |
4.6 or later |
fontVariant |
String |
Specifies whether the font for an element is rendered in small caps. |
writable |
4.6 or later |
fontWeight |
String |
Specifies the thickness of the font for an element. |
writable |
4.6 or later |
height |
String |
Specifies the height of an element. |
writable |
4.6 or later |
left |
String |
Specifies the distance of the left edge of an element from the right or left edge of the parent element. |
writable |
4.6 or later |
length |
int |
Returns the number of properties that have been explicitly set. |
read only |
4.6 or later |
letterSpacing |
String |
Specifies the spacing between the characters. |
writable |
4.6 or later |
lineHeight |
String |
Specifies the height of each line in an element. |
writable |
4.6 or later |
listStyle |
String |
Specifies any or all of the list properties. |
writable |
4.6 or later |
listStyleImage |
String |
Specifies the image used for the list marker. |
writable |
4.6 or later |
listStylePosition |
String |
Specifies the location of the list marker. |
writable |
4.6 or later |
listStyleType |
String |
Specifies the type of list marker. |
writable |
4.6 or later |
margin |
String |
Specifies the margin around all sides of an element. |
writable |
4.6 or later |
marginBottom |
String |
Specifies the margin below an element. |
writable |
4.6 or later |
marginLeft |
String |
Specifies the margin to the left of an element. |
writable |
4.6 or later |
marginRight |
String |
Specifies the margin to the right of an element. |
writable |
4.6 or later |
marginTop |
String |
Specifies the margin above an element. |
writable |
4.6 or later |
maxHeight |
String |
Specifies the maximum height for an element. |
writable |
4.6 or later |
maxWidth |
String |
Specifies the maximum width for an element. |
writable |
4.6 or later |
minHeight |
String |
Specifies the minimum height for an element. |
writable |
4.6 or later |
minWidth |
String |
Specifies the minimum width for an element. |
writable |
4.6 or later |
orphans |
String |
Specifies the minimum number of lines left at the bottom of a page. |
writable |
4.6 or later |
outline |
String |
Specifies any or all of the outline properties. |
writable |
4.6 or later |
outlineColor |
String |
Specifies the outline color for an element. |
writable |
4.6 or later |
outlineStyle |
String |
Specifies the outline style for an element. |
writable |
4.6 or later |
outlineWidth |
String |
Specifies the outline width for an element. |
writable |
4.6 or later |
overflow |
String |
Specifies the behavior when the content of an element overflows the available space for that element. |
writable |
4.6 or later |
padding |
String |
Specifies the padding around all sides of an element. |
writable |
4.6 or later |
paddingBottom |
String |
Specifies the padding applied below an element. |
writable |
4.6 or later |
paddingLeft |
String |
Specifies the padding applied to the left of an element. |
writable |
4.6 or later |
paddingRight |
String |
Specifies the padding applied to the right of an element. |
writable |
4.6 or later |
paddingTop |
String |
Specifies the padding applied above an element. |
writable |
4.6 or later |
pageBreakAfter |
String |
Specifies how the page breaks after the element are handled. |
writable |
4.6 or later |
pageBreakBefore |
String |
Specifies how the page breaks before the element are handled. |
writable |
4.6 or later |
pageBreakInside |
String |
Specifies how the page breaks within the element are handled. |
writable |
4.6 or later |
parentRule |
Returns the CSSRule that contains this declaration block. |
read only |
4.6 or later |
|
pause |
String |
Specifies any or all of the pause properties. |
writable |
4.6 or later |
pauseAfter |
String |
Specifies a pause to be observed after an element. |
writable |
4.6 or later |
pauseBefore |
String |
Specifies a pause to be observed before an element. |
writable |
4.6 or later |
pitch |
String |
Specifies the average pitch of the speaking voice. |
writable |
4.6 or later |
pitchRange |
String |
Specifies the variation in average pitch. |
writable |
4.6 or later |
playDuring |
String |
Specifies a sound to be played in the background while an element’s content is spoken. |
writable |
4.6 or later |
position |
String |
Specifies the position of the element. |
writable |
4.6 or later |
quotes |
String |
Specifies the quotation marks to use for embedded quotations. |
writable |
4.6 or later |
richness |
String |
Specifies the brightness of the speaking voice. |
writable |
4.6 or later |
right |
String |
Specifies the distance of the right edge of the of an element from the right or left edge of the parent element. |
writable |
4.6 or later |
speak |
String |
Specifies whether text will be rendered aurally. |
writable |
4.6 or later |
speakHeader |
String |
Specifies how table headers are rendered aurally. |
writable |
4.6 or later |
speakNumeral |
String |
Specifies how numerals are spoken. |
writable |
4.6 or later |
speakPunctuation |
String |
Specifies how punctuation is spoken. |
writable |
4.6 or later |
speechRate |
String |
Specifies the speaking rate. |
writable |
4.6 or later |
stress |
String |
Specifies the level of intonation of a voice. |
writable |
4.6 or later |
tableLayout |
String |
Specifies whether the column width is fixed or determined by the width of the content. |
writable |
4.6 or later |
textAlign |
String |
Specifies the horizontal alignment of the text for an element. |
writable writable |
4.6 or later |
textDecoration |
String |
Specifies the decoration applied to the text. |
writable |
4.6 or later |
textIndent |
String |
Specifies the indentation of the first line of text in a block of text. |
writable |
4.6 or later |
textTransform |
String |
Specifies how the text is capitalized. |
writable |
4.6 or later |
top |
String |
Specifies the distance of the top edge of an element above or below the parent element. |
writable |
4.6 or later |
unicodeBidi |
String |
Specifies the Unicode bidirectional algorithm to use. |
writable |
4.6 or later |
verticalAlign |
String |
Specifies the vertical alignment of an element. |
writable |
4.6 or later |
visibility |
String |
Specifies whether elements are rendered or not. |
writable |
4.6 or later |
voiceFamily |
String |
Specifies a list of voice family names. |
writable |
4.6 or later |
volume |
String |
Specifies the median volume of the wave form. |
writable |
4.6 or later |
whitespace |
String |
Specifies how white space in an element is handled. |
writable |
4.6 or later |
widows |
String |
Specifies the minimum number of lines left at the top of a page. |
writable |
4.6 or later |
width |
String |
Specifies the width of an element. |
writable |
4.6 or later |
wordSpacing |
String |
Specifies the spacing between words. |
writable |
4.6 or later |
zIndex |
String |
Specifies the stack order of an element. |
writable |
4.6 or later |
CSSStyleDeclaration methods
Method name |
Description |
Availability |
|---|---|---|
Returns the value of a CSS property as an object, if the property has been explicitly set. |
4.6 or later |
|
Returns the priority of a CSS property. |
4.6 or later |
|
Returns the value of a CSS property as a string, if the property has been explicitly set. |
4.6 or later |
|
Returns the name of the CSS property at the specified index in the collection. |
4.6 or later |
|
Removes a CSS property from the style declaration block. |
4.6 or later |
|
Sets the value of a CSS property for the style declaration block. |
4.6 or later |
Method: CSSStyleDeclaration.getPropertyPriority()
Method: CSSStyleDeclaration.getPropertyCSSValue()
The getPropertyCSSValue() method returns the value of a CSS property as an object, if the property has been explicitly set.
This method cannot access the shorthand property values. The values for shorthand properties can only be accessed and modified as strings, using CSSStyleDeclaration.getPropertyValue() and CSSStyleDeclaration.setProperty().
Method: CSSStyleDeclaration.getPropertyValue()
Method: CSSStyleDeclaration.item()
Return values
Returns the name of the CSS property at the indexth position in CSSStyleDeclaration, or an empty string if no property exists at the index position specified.