Back to the index.
This compatibility table details support for methods and properties specific to HTML elements.
This is the desktop table. See also the mobile table.
Last major update on 15 September 2014.
innerHTML
is one of the most-often used properties, since it’s so easy (not to mention fast) to take a string that contains HTML and feed it to the browser’s HTML parser. In general it works really well.
It has a few friends you should know about.
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac | |||||||||
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 |
Incom |
Almost | Yes | Yes | Yes | Yes | Yes | |||||||||||||||||
x.innerHTML x.innerHTML = "Let's <u>change</u> it!" Get or set the HTML contained by node
|
||||||||||||||||||||||||
innerText
The text contained by a tag.
Test page |
Yes | No | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.innerText x.innerText = "Let's change it!" Get or set the text contained by node Cross browser: var text = x.textContent || x.innerText |
||||||||||||||||||||||||
insertAdjacentElement
Add a DOM node next to an existing node
Test page |
Prob |
Yes | No | Yes | Yes | Yes | Yes | |||||||||||||||||
x.insertAdjacentElementL(position,DOM_node) Takes two arguments: the position (see below) and the DOM node to be inserted. Positions:
|
||||||||||||||||||||||||
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac | |||||||||
insertAdjacentHTML
Add an HTML string next to an existing node
Test page |
Prob |
Yes | Yes | Yes | Yes | Yes | Yes | |||||||||||||||||
x.insertAdjacentHTML(position,HTML_string) Takes two arguments: the position (see below) and the HTML string to be inserted. Positions:
|
||||||||||||||||||||||||
outerHTML
The HTML of a tag, including the tag itself.
Test page |
Almost | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.outerHTML x.outerHTML = "Let's <u>change</u> it!" Get or set the HTML of the entire node
|
||||||||||||||||||||||||
outerText
The text of a tag, including the tag itself.
Test page |
Almost | No | Yes | Yes | Yes | Yes | ||||||||||||||||||
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 | Yes | |||||||||||||||||
x.textContent x.textContent = "Let's change it!" Get or set the text contained by node Cross browser: var text = x.textContent || x.innerText |
||||||||||||||||||||||||
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac |
There are a few properties that exist for any HTML element. They’re treated below.
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac | |||||||||
classList
A list of class values
Test page |
No | Yes | Yes | Yes | Yes | Yes | Yes | |||||||||||||||||
x.classList An array with all the class names of element It also has the following methods:
|
||||||||||||||||||||||||
className
The class attribute.
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.className x.className = 'blue' Get or set the value of the |
||||||||||||||||||||||||
dataset
A list of data- attributes
Test page |
No | Yes | Yes | Yes | Yes | Yes | Yes | |||||||||||||||||
x.dataset Grants access to all
So the |
||||||||||||||||||||||||
dir
The dir attribute.
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
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 | Yes | ||||||||||||||||||
x.id x.id = 'otherID' Get or set the id of node |
||||||||||||||||||||||||
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac |
There are two methods specifically for select boxes. There used to be browser incompatibilities between the two versions of add()
, which is why I test both of them. The problems have disappeared.
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac | |||||||||
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 | Yes | |||||||||||||||||
x.add(y,x.options[x.options.length]) Adds an option to a select box, where Say again? Yup, this is the complicated way. One wonders what the person who thought this up was smoking. It even used to be a W3C standard. | ||||||||||||||||||||||||
add(opt,ind)
Add an option to a select box. The second argument is an index number.
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.add(y,2) Adds an option to a select box, where This is the simple way. Microsoft pushed this, and I’m glad they won because they were right. |
||||||||||||||||||||||||
remove()
Remove an option from a select box
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.remove(1) Remove the second option from select |
Then a whole slew of table-specific methods and properties that nobody ever uses.
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac | |||||||||
caption
The caption of a table
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.caption Access the caption of table |
||||||||||||||||||||||||
cellIndex
The index number of a cell in its row
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.cellIndex The index number of element |
||||||||||||||||||||||||
cellPadding
The ancient attribute
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
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 | Yes | ||||||||||||||||||
x.rows[1].cells A nodeList with all cells of the second row of table |
||||||||||||||||||||||||
cellSpacing
The ancient attribute
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.cellSpacing = 10 Set the cell spacing of table |
||||||||||||||||||||||||
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac | |||||||||
createCaption()
Create a caption for a table
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.createCaption() If table |
||||||||||||||||||||||||
createTFoot()
Create a tFoot element
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.createTFoot() If table |
||||||||||||||||||||||||
createTHead()
Create a tHead element
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.createTHead() If table |
||||||||||||||||||||||||
deleteCaption()
Delete the caption of a table
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.deleteCaption() Delete the caption of table |
||||||||||||||||||||||||
deleteCell()
Delete a table cell
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
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 | Yes | ||||||||||||||||||
x.deleteRow(1) Delete the second row of table x.tBodies[1].deleteRow(1) Delete the second row of the second |
||||||||||||||||||||||||
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac | |||||||||
deleteTFoot()
Delete the tFoot of a table
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.deleteTFoot() Delete the tFoot of table |
||||||||||||||||||||||||
deleteTHead()
Delete the tHead of a table
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.deleteTHead() Delete the tHead of table |
||||||||||||||||||||||||
insertCell()
Insert a table cell
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.rows[0].insertCell(1) Insert a |
||||||||||||||||||||||||
insertRow()
Insert a table row
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.insertRow(1) Insert a |
||||||||||||||||||||||||
moveRow()
Move a row from one position to another. Microsoft proprietary.
Test page |
Yes | No | No | No | No | No | ||||||||||||||||||
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 | Yes | Yes | ||||||||||||||||||
x.rowIndex The index number of element Note that browsers should move any
|
||||||||||||||||||||||||
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac | |||||||||
rows[]
An array of all rows in a table or table section
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
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 | Yes | ||||||||||||||||||
x.sectionRowIndex The index number of element |
||||||||||||||||||||||||
tBodies[]
An array with all tBody elements
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.tBodiesAn array with all TBodies of table x .
|
||||||||||||||||||||||||
tFoot
The tFoot of a table
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.tFootAccess the tFoot of x , which must be a table.
|
||||||||||||||||||||||||
tHead
The tHead of a table
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
x.tHeadAccess the tHead of x , which must be a table.
|
||||||||||||||||||||||||
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac |
Finally, some properties of HTML documents.
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac | |||||||||
activeElement
The element that currently has the user focus
Test page |
Prob |
Yes | Yes | Incom |
Yes | Incom |
Incom |
Incom |
Incom |
|||||||||||||||
document.activeElement I test this property with form fields, links, and buttons.
|
||||||||||||||||||||||||
body
The body tag
Test page |
Yes | Yes | Yes | Yes | Yes | Yes | ||||||||||||||||||
document.body Represents the BODY tag. |
||||||||||||||||||||||||
compatMode
Strict mode or Quirks mode
Test page Strict Test page Quirks |
6 | Yes | Yes | Yes | Yes | Yes | Yes | |||||||||||||||||
document.compatMode Returns the compatibility mode of the document:
|
||||||||||||||||||||||||
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac | |||||||||
defaultView
The window the document is displayed in
Test page |
No | Yes | Yes | Yes | Yes | Yes | Yes | |||||||||||||||||
document.defaultView Refers to the window. I have no idea why we need yet another reference to the window. |
||||||||||||||||||||||||
doctype
The document’s doctype
Test page Strict Test page Quirks |
No | Yes | Yes | Yes | Yes | Yes | Yes | |||||||||||||||||
document.doctype |
||||||||||||||||||||||||
lastModified
The document’s last modification date; IF the server gives this information
Test page |
Prob |
Yes | Yes | Yes | Yes | Yes | Yes | |||||||||||||||||
document.lastModified |
||||||||||||||||||||||||
parentWindow
The window the document is displayed in
Test page |
Yes | No | No | No | No | No | ||||||||||||||||||
document.parentWindow Refers to the window. I have no idea why we need yet another reference to the window. |
||||||||||||||||||||||||
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac |
Character encoding is tricky. These tests were done on my devices, which have English or Dutch as their default language. (Two Android phones originally come from China, though.)
See the WHAT-WG spec for some common encodings and labels. A label is a name that points to a certain encoding. Windows-1252, ISO-8859-1, and Latin-1 are all labels for the same encoding. They’re case insensitive, but strictly speaking the dash in Latin-1 is not allowed. I’m going to ignore that, though.
I test this with two test pages. The expected results are in the table below, where “default” means the browser’s default encoding, which is returned by characterSet
on the test page without an encoding definition and is shown in the first row of the compatibility table below.
Property | UTF-8 definition | No charset definition |
---|---|---|
characterSet | UTF-8 | Default |
charset | UTF-8 | Default |
defaultCharset | Default | Default |
All browsers get the UTF-8 right; the problem lies in defaultCharset
, which sometimes doesn’t return the default encoding.
Method or property | Internet Explorer | Firefox | Safari | Chrome | Opera | Yandex | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7 and lower | 8 | 9 | 10 | 11 | 32 Win | 32 Mac | 32 Linux | 7 | 37 Win | 37 Mac | 37 Linux | 24 Win | 24 Mac | 14 Win | 14 Mac | |||||||||
Character set, default
What is the browser’s default character set?
Test page |
Win | Win | ISO | ISO | ISO | ISO | ||||||||||||||||||
The value |
||||||||||||||||||||||||
characterSet
The document’s defined character set
Test page |
No | Yes | Yes | Yes | Yes | Yes | Yes | |||||||||||||||||
document.characterSet The actually-defined character set of the page. With a UTF-8 declaration that should be UTF-8; without one the default character set. |
||||||||||||||||||||||||
charSet
The document’s defined character set
Test page |
Prob |
Yes | No | Yes | Yes | Yes | Yes | |||||||||||||||||
document.charSet The actually-defined character set of the page. With a UTF-8 declaration that should be UTF-8; without one the default character set. |
||||||||||||||||||||||||
defaultCharset
The document’s default character set in the absence of any declaration
Test page |
Prob |
Yes | No | Yes | Yes | Yes | Yes | |||||||||||||||||
document.defaultCharset Should always return the value that the other two properties return on a page without a character set definition. |
Desktop browser test array 2.0; September 2014