Page last changed 3 months ago
Last major update on 18 July 2010 .
You can also view the previous version , which was created in September 2005 and still features IE Mac.
If you'd like to have some practical examples of what you can do with the W3C DOM, read my book ppk on JavaScript , especially chapter 8.
This compatibility table details support for the W3C DOM HTML Level 1 and 2 modules in all modern browsers.
There are four tables on this page. You must know the first two tables by heart, the other two are far less important.
First some properties of all HTML elements. All of them are read/write, and the average DOM script uses at least two or three of them.
You must know these properties by heart.
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 | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
className
The class attribute. Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.className x.className = 'blue' Get or set the value of the |
||||||||||||||||||||||||
dir
The dir attribute. Test page |
Almost | Yes | Yes | Almost | Almost | Yes | To be tested | |||||||||||||||||
x.dir x.dir = 'rtl' Get or set the text direction (ltr or rtl, left to right or right to left) of element
|
||||||||||||||||||||||||
id
The id attribute. Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.id x.id = 'otherID' Get or set the id of node |
||||||||||||||||||||||||
innerHTML
The HTML contained by a tag, as a string.Originally a Microsoft extension, innerHTML is so useful that all other browsers support it, too. Test page see also the table test page |
Almost | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.innerHTML x.innerHTML = "Let's <u>change</u> it!" Get or set the HTML contained by node In general
|
||||||||||||||||||||||||
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 | |||||||
innerText
The text contained by a tag. Test page |
Yes | No | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.innerText x.innerText = "Let's change it!" Get or set the text contained by node Cross browser: var text = x.innerText || x.textContent |
||||||||||||||||||||||||
outerHTML
The HTML of a tag, including the tag itself. Test page |
Almost | No | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.outerHTML x.outerHTML = "Let's <u>change</u> it!" Get or set the HTML of the entire node Once you’ve changed the |
||||||||||||||||||||||||
outerText
The text of a tag, including the tag itself. Test page |
Almost | No | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.outerText x.outerText = "Let's change it!" Get or set the text contained by node See |
||||||||||||||||||||||||
textContent
The text contained by a tag. Test page |
No | Yes | Yes | Yes | Yes | Yes | To be tested | |||||||||||||||||
x.textContent x.textContent = "Let's change it!" Get or set the text contained by node Cross browser: var text = x.innerText || x.textContent |
||||||||||||||||||||||||
title
The title attribute. Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.title x.title = 'Changed' Get or set the title attribute of node
|
||||||||||||||||||||||||
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 |
Some miscellaneous items, the first two of which are sometimes 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 | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
body
The body tag Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
document.body Represents the BODY tag. |
||||||||||||||||||||||||
compatMode
Strict mode or Quirks mode Test page Strict Test page Quirks |
No | Yes | Yes | Yes | Yes | Yes | To be tested | |||||||||||||||||
document.compatMode Returns the compatibility mode of the document:
|
||||||||||||||||||||||||
createHTMLDocument()
Create an HTML document Test page |
No | Yes | No | Yes | Yes | Yes | To be tested | |||||||||||||||||
document.implementation.createHTMLDocument('Title') Create an HTML document consisting of |
||||||||||||||||||||||||
defaultView
The window the document is displayed in Test page |
No | Yes | Yes | Yes | Yes | Yes | To be tested | |||||||||||||||||
document.defaultView Refers to the window. I have no idea why we need yet another reference to the window. |
||||||||||||||||||||||||
parentWindow
The window the document is displayed in Test page |
Yes | No | No | No | Yes | To be tested | ||||||||||||||||||
document.parentWindow Refers to the window. I have no idea why we need yet another reference to the window. |
||||||||||||||||||||||||
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 |
Two new methods for select boxes.
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 | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
add(opt,opt)
Add an option to a select box. The second argument is the option after which you want to insert the new option. Test page |
No | Yes | Yes | Yes | Yes | Yes | To be tested | |||||||||||||||||
x.add(y,x.options[x.options.length]) Adds an option to a select box, where The W3C approved way (that is much too complicated) requires you to refer to the option object after which the new option is inserted. |
||||||||||||||||||||||||
add(opt,ind)
Add an option to a select box. The second argument is an index number. Test page |
Yes | No | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.add(y,2) Adds an option to a select box, where The Microsoft way: give the index number of the option after which you want to insert the new option. I side with Microsoft here; W3C's implementation is far too complicated. |
||||||||||||||||||||||||
remove()
Remove an option from a select box Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.remove(1) Remove the second option from select |
All methods, arrays and properties for child elements of tables. My W3C DOM vs. innerHTML tests show that these methods are the slowest way to build a table in Explorer on Windows. Use with care.
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 | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
caption
The caption of a table Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.caption Access the caption of table |
||||||||||||||||||||||||
cellIndex
The index number of a cell in its row Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.cellIndex The index number of element |
||||||||||||||||||||||||
cellPadding
The ancient attribute Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.cellPadding = 10 Sets the cell padding of table
|
||||||||||||||||||||||||
cells[]
An array with all cells in a row Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.rows[1].cells A nodeList with all cells of the second row of table |
||||||||||||||||||||||||
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 | |||||||
cellSpacing
The ancient attribute Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.cellSpacing = 10 Set the cell spacing of table |
||||||||||||||||||||||||
createCaption()
Create a caption for a table Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.createCaption() If table |
||||||||||||||||||||||||
createTFoot()
Create a tFoot element Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.createTFoot() If table |
||||||||||||||||||||||||
createTHead()
Create a tHead element Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.createTHead() If table |
||||||||||||||||||||||||
deleteCaption()
Delete the caption of a table Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.deleteCaption() Delete the caption of table |
||||||||||||||||||||||||
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 | |||||||
deleteCell()
Delete a table cell Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.rows[1].deleteCell(0) Delete the first cell of the second row of table |
||||||||||||||||||||||||
deleteRow()
Delete a table row Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.deleteRow(1) Delete the second row of table x.tBodies[1].deleteRow(1) Delete the second row of the second |
||||||||||||||||||||||||
deleteTFoot()
Delete the tFoot of a table Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.deleteTFoot() Delete the tFoot of table |
||||||||||||||||||||||||
deleteTHead()
Delete the tHead of a table Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.deleteTHead() Delete the tHead of table |
||||||||||||||||||||||||
frame
A border around an entire table Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.frame = 'lhs' Set the Possible values: void, above, below, hsides, vsides, lhs, rhs, box, border |
||||||||||||||||||||||||
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 | |||||||
insertCell()
Insert a table cell Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.rows[0].insertCell(1) Insert a |
||||||||||||||||||||||||
insertRow()
Insert a table row Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.insertRow(1) Insert a |
||||||||||||||||||||||||
moveRow()
Move a row from one position to another. Microsoft proprietary. Test page |
Yes | No | No | No | No | To be tested | ||||||||||||||||||
moveRow(0,3) Move row with index 0 to index 3. |
||||||||||||||||||||||||
rowIndex
The index number of a row in the table. Disregards table sections. Test page |
Yes | Yes | Yes | Yes | Incorrect | To be tested | ||||||||||||||||||
x.rowIndex The index number of element Note that browsers should move any
|
||||||||||||||||||||||||
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 | |||||||
rows[]
An array of all rows in a table or table section Test page |
Yes | Yes | Yes | Yes | Incorrect | To be tested | ||||||||||||||||||
x.rows A nodeList with all rows of table
|
||||||||||||||||||||||||
sectionRowIndex
The index number of a row in the table section Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.sectionRowIndex The index number of element |
||||||||||||||||||||||||
tBodies[]
An array with all tBody elements Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.tBodiesAn array with all TBodies of table x . |
||||||||||||||||||||||||
tFoot
The tFoot of a table Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.tFootAccess the tFoot of x , which must be a table. |
||||||||||||||||||||||||
tHead
The tHead of a table Test page |
Yes | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||||
x.tHeadAccess the tHead of x , which must be a table. |
||||||||||||||||||||||||
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 |