Last major update on 19 July 2010.
This page has been translated into Romanian.
You can also view the previous version.
This compatibility table details support for the W3C DOM CSS Level 2 modules and assorted Microsoft extensions in all modern browsers.
Want these Tables updated? Join the donation drive.
This page contains five tables. The first three are quite important, the last two aren't.
Basic style manipulation starts with accessing styles of individual HTML elements. The
important style
property gives access to the inline styles of the element.
Finding out which non-inline styles apply to an element is more difficult. See the
Get styles page for a practical example.
Selector | IE 5.5 | IE 6 | IE 7 | IE8 | IE9 pr3 | FF 3.0 | FF 3.5 | FF 3.6 | FF 4b1 | Saf 4.0 Win | Saf 5.0 Win | Chrome 4 | Chrome 5 | Opera 10.10 | Opera 10.53 | Opera 10.60 | Konqueror 4.x | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
currentStyle
The current style of the element, however this style is set
Test page Microsoft |
Yes | No | No | No | Yes | To be tested | |||||||||||||
x.currentStyle Returns the actual style of element |
|||||||||||||||||||
getComputed
The current style of the element, however this style is set
Test page W3C |
No | Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||
window.getComputedStyle(x,null).color Read out the current color style of element |
|||||||||||||||||||
style
The inline style of the element
Test page |
Almost | Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||
x.style Access the inline styles of element You can also set it:
|
|||||||||||||||||||
No | Yes | No | No | No | Yes | To be tested | |||||||||||||
x.style = 'font-size: 150%' Change the inline styles to only |
|||||||||||||||||||
Read only | Yes | Yes | Yes | Yes | Yes | To be tested | |||||||||||||
document.styleSheets[1].cssRules[0].style Access the styles in the first rule of the second style sheet. These, too, can be set: (IE uses |
|||||||||||||||||||
Selector | IE 5.5 | IE 6 | IE 7 | IE8 | IE9 pr3 | FF 3.0 | FF 3.5 | FF 3.6 | FF 4b1 | Saf 4.0 Win | Saf 5.0 Win | Chrome 4 | Chrome 5 | Opera 10.10 | Opera 10.53 | Opera 10.60 | Konqueror 4.x |
You can access and change entire style sheets. See the Change style sheet page for an introduction to these properties and the inevitable browser compatibility problems.
Selector | IE 5.5 | IE 6 | IE 7 | IE8 | IE9 pr3 | FF 3.0 | FF 3.5 | FF 3.6 | FF 4b1 | Saf 4.0 Win | Saf 5.0 Win | Chrome 4 | Chrome 5 | Opera 10.10 | Opera 10.53 | Opera 10.60 | Konqueror 4.x | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cssRules[]
An array with all rules in a stylesheet.
Test page |
No | Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||
document.styleSheets[1].cssRules[1] Access the second rule of the second style sheet in the document. |
|||||||||||||||||||
imports[]
An array with all imported style sheets in a style sheet
Test page |
Yes | No | No | No | No | To be tested | |||||||||||||
document.styleSheets[1].imports Access all style sheets that are imported by the second style sheet in the document. |
|||||||||||||||||||
rules[]
An array with all rules in a stylesheet.
Test page |
Incor |
No | Yes | Yes | No | To be tested | |||||||||||||
document.styleSheets[1].rules[1] Access the second rule of the second style sheet in the document.
|
|||||||||||||||||||
styleSheets[]
An array with all stylesheets in the document
Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | |||||||||||||
document.styleSheets[1] Access the second style sheet (linked or embedded) in the document. |
|||||||||||||||||||
Selector | IE 5.5 | IE 6 | IE 7 | IE8 | IE9 pr3 | FF 3.0 | FF 3.5 | FF 3.6 | FF 4b1 | Saf 4.0 Win | Saf 5.0 Win | Chrome 4 | Chrome 5 | Opera 10.10 | Opera 10.53 | Opera 10.60 | Konqueror 4.x |
You can change entire style sheets, which means that the styles you change will apply to the whole HTML page, not just one element. There are some cute old-fashioned browser compatibility problems here.
Selector | IE 5.5 | IE 6 | IE 7 | IE8 | IE9 pr3 | FF 3.0 | FF 3.5 | FF 3.6 | FF 4b1 | Saf 4.0 Win | Saf 5.0 Win | Chrome 4 | Chrome 5 | Opera 10.10 | Opera 10.53 | Opera 10.60 | Konqueror 4.x | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
addRule()
Add a rule into a stylesheet the Microsoft way
Test page |
Yes | No | Yes | Yes | No | To be tested | |||||||||||||
document.styleSheets[1].addRule('pre', 'font: 14px verdana') Add the rule |
|||||||||||||||||||
deleteRule()
Delete a rule from a stylesheet the W3C way
Test page |
No | Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||
document.styleSheets[1].deleteRule(1) Delete the second rule of the second style sheet in the document. |
|||||||||||||||||||
insertRule()
Insert a rule into a stylesheet the W3C way
Test page |
No | Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||
var x = document.styleSheets[1]; x.insertRule('pre {font: 14px verdana}',x.cssRules.length) Insert the rule Unfortunately the second argument is required. It should default to |
|||||||||||||||||||
removeRule()
Remove a rule from a stylesheet the Microsoft way
Test page |
Yes | No | Yes | Yes | No | To be tested | |||||||||||||
document.styleSheets[1].removeRule(1) Remove the second rule from the second style sheet in the document. |
|||||||||||||||||||
Selector | IE 5.5 | IE 6 | IE 7 | IE8 | IE9 pr3 | FF 3.0 | FF 3.5 | FF 3.6 | FF 4b1 | Saf 4.0 Win | Saf 5.0 Win | Chrome 4 | Chrome 5 | Opera 10.10 | Opera 10.53 | Opera 10.60 | Konqueror 4.x |
Style sheets and their rules have several properties. They aren't very interesting, and browser incompatibilities make sure that they won't be used much.
Selector | IE 5.5 | IE 6 | IE 7 | IE8 | IE9 pr3 | FF 3.0 | FF 3.5 | FF 3.6 | FF 4b1 | Saf 4.0 Win | Saf 5.0 Win | Chrome 4 | Chrome 5 | Opera 10.10 | Opera 10.53 | Opera 10.60 | Konqueror 4.x | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cssText
The CSS of a rule as a string.
Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | |||||||||||||
x.style.cssText Returns the entire inline style of element |
|||||||||||||||||||
Yes | No | No | No | No | To be tested | ||||||||||||||
document.styleSheets[1].cssText Returns the entire content of the style sheet. |
|||||||||||||||||||
No | Yes | Yes | Yes | Yes | Yes | To be tested | |||||||||||||
document.styleSheets[1].cssRules[1].cssText Returns the entire text of the rule (for instance (Obviously, IE needs |
|||||||||||||||||||
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||
document.styleSheets[1].cssRules[1].style.cssText Returns all declarations of the rule (for instance (Obviously, IE needs |
|||||||||||||||||||
disabled
Whether the stylesheet is disabled
Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | |||||||||||||
document.styleSheets[1].disabled = true Disable the second style sheet of the document. (Setting it to |
|||||||||||||||||||
href
The href of a stylesheet
Test page |
Yes+ | Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||
document.styleSheet[0].href Get the
|
|||||||||||||||||||
selectorText
The selector of a rule as a string
Test page |
Yes | Incor |
Yes | Yes | Yes | Yes+ | To be tested | ||||||||||||
document.styleSheets[1].cssRules[1].selectorText Get the selector text of the second rule in the second style sheet in the document. Note that some browsers return UPPER CASE selector texts even when the style sheet contains
lower case selectors. Use
|
|||||||||||||||||||
Selector | IE 5.5 | IE 6 | IE 7 | IE8 | IE9 pr3 | FF 3.0 | FF 3.5 | FF 3.6 | FF 4b1 | Saf 4.0 Win | Saf 5.0 Win | Chrome 4 | Chrome 5 | Opera 10.10 | Opera 10.53 | Opera 10.60 | Konqueror 4.x |
Miscellaneous stuff. Generally not important.
Selector | IE 5.5 | IE 6 | IE 7 | IE8 | IE9 pr3 | FF 3.0 | FF 3.5 | FF 3.6 | FF 4b1 | Saf 4.0 Win | Saf 5.0 Win | Chrome 4 | Chrome 5 | Opera 10.10 | Opera 10.53 | Opera 10.60 | Konqueror 4.x | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
create
Create a style sheet
Test page |
Yes | No | No | No | No | To be tested | |||||||||||||
document.createStyleSheet('extrastyle.css') Create an extra style (sheet) and append it to the styleSheets[] array. |
|||||||||||||||||||
getProperty
Get the property priority (!important or not)
Test page |
No | Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||
document.styleSheets[1].cssRules[1].style.getPropertyPriority('color') Returns (Obviously, IE needs |
|||||||||||||||||||
getProperty
Get the value of a style property
Test page |
No | Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||
document.getElementById('test').style.getPropertyValue('color') document.styleSheets[1].cssRules[1].style.getPropertyValue('color') Get the color declaration of the style object. This works on all style objects. Of course,
reading out |
|||||||||||||||||||
ownerNode
The owner of a style sheet
Test page |
No | Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||
document.styleSheets[1].ownerNode Access the owner node of the style sheet, usually a |
|||||||||||||||||||
parent
The stylesheet a declaration is part of
Test page |
No | Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||
document.styleSheets[1].cssRules[1].parentStyleSheet Access the parent style sheet of the rule, which is once again |
|||||||||||||||||||
remove
Remove a style declaration entirely
Test page |
No | Yes | Yes | Yes | Yes | Incom |
To be tested | ||||||||||||
document.styleSheets[1].cssRules[1].style.removeProperty('color') document.getElementById('test').style.removeProperty('color') Remove the color declaration from the second rule of the second style sheet on the page or the element with ID="test".
|
|||||||||||||||||||
set
Set a style property
Test page |
No | Yes | Yes | Yes | Yes | To be tested | |||||||||||||
x.style.setProperty('color','#00cc00',null) document.styleSheets[1].cssRules[1].style.setProperty('color','#00cc00',null) Set the color of As usual, the |
|||||||||||||||||||
Selector | IE 5.5 | IE 6 | IE 7 | IE8 | IE9 pr3 | FF 3.0 | FF 3.5 | FF 3.6 | FF 4b1 | Saf 4.0 Win | Saf 5.0 Win | Chrome 4 | Chrome 5 | Opera 10.10 | Opera 10.53 | Opera 10.60 | Konqueror 4.x |