W3C DOM Compatibility - HTML

Back to the index.

This compatibility table details support for methods and properties specific to HTML elements.

This is the mobile table. See also the desktop table.

Last major update on 22 September 2014.

innerHTML and friends

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.

iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11
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
Yes Yes Yes Yes Yes Incomplete Yes Incomplete Almost Yes
x.innerHTML
x.innerHTML = "Let's <u>change</u> it!"

Get or set the HTML contained by node x.

  • If you change the innerHTML of a script tag the browser doesn’t recognize the new script and you can’t execute it. Don’t do this.
  • The order of the attributes on the HTML element may be off in IE. Not a big deal, but still.
  • If you remove elements through innerHTML in IE, their content is wiped and only the element itself (i.e. opening and closing tags) remain. If you want to remove nodes that you may want to reinsert at a later time, use DOM methods such as removeChild().
  • In IE9 and lower innerHTML refuses to work on tables and selects. Solve this by using pure DOM methods instead. See this explanation of the table behaviour by innerHTML’s inventor. I assume something similar goes for selects.
  • Xpress doesn’t support the writing of selects and style elements.
innerText
The text contained by a tag.

Test page
Yes Yes Yes Yes Yes No Yes Yes No
x.innerText
x.innerText = "Let's change it!"

Get or set the text contained by node x. Any HTML tags in the node are ignored, though their text content is added to the innerText. If you set innerText all inner HTML elements are removed.

Cross browser:

var text = x.textContent || x.innerText
insertAdjacentElement
Add a DOM node next to an existing node

Test page
Yes Yes Yes Yes Yes No Yes Yes No
x.insertAdjacentElementL(position,DOM_node)

Takes two arguments: the position (see below) and the DOM node to be inserted.

Positions:

  • beforebegin: before element x.
  • afterbegin: as first child of element x.
  • beforeend: as last child of element x.
  • afterend: after element x.
iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11
insertAdjacentHTML
Add an HTML string next to an existing node

Test page
Yes Yes Yes Yes Yes No Yes Yes Yes
x.insertAdjacentHTML(position,HTML_string)

Takes two arguments: the position (see below) and the HTML string to be inserted.

Positions:

  • beforebegin: before element x.
  • afterbegin: added to element x’s innerHTML at the start.
  • beforeend: added to element x’s innerHTML at the end.
  • afterend: after element x.
outerHTML
The HTML of a tag, including the tag itself.

Test page
Yes Yes Yes Yes Yes No Yes Almost Yes
x.outerHTML
x.outerHTML = "Let's <u>change</u> it!"

Get or set the HTML of the entire node x, including the outermost tag (element x itself).

  • IE8 returns UPPER CASE tags, even though the source is lower case.
  • Once you’ve changed the outerHTML, element x is removed entirely and replaced by the HTML you’ve specified. However, variable x still refers to the removed element that now floats in “DOM hyperspace.” In IE its content is removed, though, because of the bug mentioned under innerHTML.
outerText
The text of a tag, including the tag itself.

Test page
Yes Yes Yes Yes Yes No Yes Yes No
x.outerText
x.outerText = "Let's change it!"

Get or set the text contained by node x. Exactly the same as innerText except that node x is also overwritten and removed when you set outerText.

See outerHTML note about element x.

textContent
The text contained by a tag.

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.textContent
x.textContent = "Let's change it!"

Get or set the text contained by node x. Any HTML tags in the node are ignored, though their text content is added to the textContent.

Cross browser:

var text = x.textContent || x.innerText
iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11

HTML element properties

There are a few properties that exist for any HTML element. They’re treated below.

iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11
classList
A list of class values

Test page
Yes No Yes Yes Yes Yes Yes No Yes No Yes Yes
x.classList

An array with all the class names of element x. You can read it out as an array, where each member contains one class name. If you change it to a string (x.classList.toString()) you should get the same result as with className.

It also has the following methods:

  • add(className). className is added to the element’s classList.
  • contains(className). Returns true if the element’s classList currently contains className; returns false otherwise.
  • remove(className). className is removed from the element’s classList.
  • toggle(className). className is added if it’s absent; removed if it’s present.
className
The class attribute.

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.className
x.className = 'blue'

Get or set the value of the class attribute of node x, if any.

dataset
A list of data- attributes

Test page
Yes No Yes Yes Yes Yes No Yes No Yes No Yes Yes
x.dataset

Grants access to all data-* attributes on element x. Each attribute is a property of x.dataset. The names are complicated, though:

  1. Chop off data-.
  2. Any lower case character preceded by a dash becomes upper case, while the dash is removed. (Same as with CSS property names.)

So the data-a-complicated-value attribute becomes x.dataset.aComplicatedValue.

dir
The dir attribute.

Test page
Yes Yes Yes Yes Yes Yes No 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 x. For the moment dir serves as a glorified align.

id
The id attribute.

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.id
x.id = 'otherID'

Get or set the id of node x, which must be a tag. If no ID is specified in the HTML, it is empty.

iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11

Select boxes

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.

iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11
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
Yes Yes Yes Yes Yes Yes Yes Yes
x.add(y,x.options[x.options.length])

Adds an option to a select box, where x is the select box and y is the new option. The second argument is the option object before which the new option should be inserted.

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 No Yes Yes Yes
x.add(y,2)

Adds an option to a select box, where x is the select box and y is the new option. The second argument is simply an index.

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 Yes Yes
x.remove(1)

Remove the second option from select x.

Tables

Then a whole slew of table-specific methods and properties that nobody ever uses.

iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11
caption
The caption of a table

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.caption

Access the caption of table x.

cellIndex
The index number of a cell in its row

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.cellIndex

The index number of element x, which must be a <td> or <th>, in its row (<tr>).

cellPadding
The ancient attribute

Test page
Yes Yes Yes Yes Yes Yes No Yes Yes Yes
x.cellPadding = 10

Sets the cell padding of table x to 10 pixels. cellPadding is overruled by any CSS padding declaration. When you set cellPadding, the changes only apply to table cells without any CSS padding.

cells[]
An array with all cells in a row

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.rows[1].cells

A nodeList with all cells of the second row of table x. Contains both <td>s and <th>s.

cellSpacing
The ancient attribute

Test page
Yes Yes Yes Yes Yes Yes No Yes Yes Yes
x.cellSpacing = 10

Set the cell spacing of table x to 10.

iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11
createCaption()
Create a caption for a table

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.createCaption()

If table x already has a caption this method returns the caption. If not, a new caption is created.

createTFoot()
Create a tFoot element

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.createTFoot()

If table x has a <tfoot>, get it. If not, create a <tfoot> and append it to the table.

createTHead()
Create a tHead element

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.createTHead()

If table x has a <thead>, get it. If not, create a <thead> and append it to the table.

deleteCaption()
Delete the caption of a table

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.deleteCaption()

Delete the caption of table x, if present.

deleteCell()
Delete a table cell

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.rows[1].deleteCell(0)

Delete the first cell of the second row of table x.

deleteRow()
Delete a table row

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.deleteRow(1)

Delete the second row of table x.

x.tBodies[1].deleteRow(1)

Delete the second row of the second <tbody> of table x.

iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11
deleteTFoot()
Delete the tFoot of a table

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.deleteTFoot()

Delete the tFoot of table x.

deleteTHead()
Delete the tHead of a table

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.deleteTHead()

Delete the tHead of table x.

insertCell()
Insert a table cell

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.rows[0].insertCell(1)

Insert a <td> the first <tr> of table x, as the second <td>.

insertRow()
Insert a table row

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.insertRow(1)

Insert a <tr> into table x as the second <tr>.

moveRow()
Move a row from one position to another. Microsoft proprietary.

Test page
No No No No No No Yes 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 Incorrect Yes Yes Yes
x.rowIndex

The index number of element x, which must be a <tr>, in its table, regardless of table section (tHead, tBody, tFoot).

Note that browsers should move any <thead> to the top of the table, and any <tfoot> to the bottom. Therefore rows should be counted in the order <thead>-rows, <tbody>-rows, <tfoot>-rows: the order in which they're visible in the rendered page.

  • Opera Presto keeps to the source code order (where the <tfoot> precedes the <tbody>.)
iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11
rows[]
An array of all rows in a table or table section

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.rows

A nodeList with all rows of table x.

  • Safari 3.0 and Opera keep to the source order (where the <tfoot> precedes the <tbody>)
sectionRowIndex
The index number of a row in the table section

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.sectionRowIndex

The index number of element x, which must be a <tr>, in its table section (tHead, tBody, tFoot).

tBodies[]
An array with all tBody elements

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.tBodies
An array with all TBodies of table x.
tFoot
The tFoot of a table

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.tFoot
Access the tFoot of x, which must be a table.
tHead
The tHead of a table

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
x.tHead
Access the tHead of x, which must be a table.
iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11

Document

Finally, some properties of HTML documents.

iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11
activeElement
The element that currently has the user focus

Test page
1 1 1 1+3 1+3 1+2 1 Badly usable Yes 1 Yes Yes
document.activeElement

I test this property with form fields, links, and buttons.

1: supported on form fields
2: supported on links
3: supported on buttons

  • Xiaomi Android 4 DOES support it for buttons. That’s because it’s really a Chromium, which I didn’t yet know when I created this table.
  • This is the sort of property proxy browsers find very hard to support. The test kind-of works in Opera Mini and Nokia Xpress, except on the inputs. That’s because they refuse to send a JavaScript event, and not because they fundamentally don’t support it. UC Mini really doesn’t support it.
    The point here is that proxy browsers don’t handle Javascript on the client, so that, even if the browser can theoretically handle this property, it’s never updated without a round-trip to the server, which kind-of defeats the purpose.
body
The body tag

Test page
Yes Yes Yes Yes Yes Yes Yes Yes
document.body

Represents the BODY tag.

compatMode
Strict mode or Quirks mode

Test page Strict
Test page Quirks
Yes Yes Yes Yes Yes Yes Yes Yes
document.compatMode

Returns the compatibility mode of the document: BackCompat (Quirks Mode) or CSS1Compat (Strict Mode). See the Quirks and Strict Mode page for an explanation.

  • IE 5.5 doesn't support this property, but it doesn't need to. It's permanently locked in Quirks Mode.
defaultView
The window the document is displayed in

Test page
Yes Yes 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
Yes Yes Yes Yes Yes Yes Yes Yes
document.doctype
lastModified
The document’s last modification date; IF the server gives this information

Test page
Yes No Yes Yes Yes Yes Yes Yes Yes
document.lastModified
parentWindow
The window the document is displayed in

Test page
No No No No No No Yes No Yes No
document.parentWindow

Refers to the window. I have no idea why we need yet another reference to the window.

iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11

Character encoding

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.

iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11
Character set, default
What is the browser’s default character set?

Test page
ISO Mostly ISO ISO GBK / ISO ISO ISO GBK Win ISO Win Win

The value charSet and characterSet return when there’s no character declaration.

ISO
ISO-8859-1 (case insensitive)
Win
Windows-1252 (case insensitive)
GBK
GBK; a Chinese encoding
  • The Sony e-reader and Xiaomi always report UTF-8, regardless of character set definition.
  • The English UC 9 reports ISO; the two Chinese ones GBK. That makes sense, given their default language. (I can’t judge if GBK makes sense in a Chinese context, though.)
characterSet
The document’s defined character set

Test page
Yes Yes 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.

  • The Sony e-reader and Xiaomi always report UTF-8, regardless of character set definition.
charSet
The document’s defined character set

Test page
Yes Yes Yes Yes Yes No Yes Yes No
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.

  • The Sony e-reader and Xiaomi always report UTF-8, regardless of character set definition.
defaultCharset
The document’s default character set in the absence of any declaration

Test page
Yes Mostly incorrect Yes Incorrect Yes Yes Yes No Incorrect Yes No
document.defaultCharset

Should always return the value that the other two properties return on a page without a character set definition.

  • On Android WebKit this property returns Latin-1, but it should return ISO-8859-1, which both other properties return on a page without a character set definition. Exceptions:
    • the Sony e-reader and the Xiaomi use UTF-8 (for all character properties). This means they support this property correctly.
    • the Whoop Echo has auto-detector
    • the Galaxy Note doesn’t support it
  • Cyanogen’s Chromium 33 and Dolphin also return Latin-1.
  • Nintendo returns UTF-8
iOS Android Chromium UC 9 BlackBerry Nokia Xpress UC Mini Opera Nintendo Dolphin IE FF And
7 8 2 4 Sa Puf Cy Op Go 6 7 10 Mini Classic 9 10 11

Browsers

Mobile browser test array 2.0; September 2014

This revision has quite a few changes from the 1.3 one; see my notes.

iOS 7
WebKit 537
Default browser on iPad 2 with iOS 7.1.2
iOS 8
WebKit 600
Default browser on iPhone 4S with iOS 8.0
Android 2
WebKit 533
Default browser on HTC Legend, Android 2.2
Default browser on Samsung Galaxy Pocket, Android 2.3.6
Default browser on Sony Reader PRS-T3. I’ve heard it’s Android 2-based, but of course it’s nearly impossible to get some actual information.
Android 4
WebKit 534
Default browser on Xiaomi M2, Android 4.1.1
Default browser on Huawei C8813, Android 4.1.1
Default browser on Samsung Galaxy Note I, Android 4.1.2
Default browser on Sony Xperia S, Android 4.1.2
Default browser on LG L5, Android 4.1.2
Default browser on Wolfgang AT-AS45FW, Android 4.2.2 (see note below)
Default browser on HTC One X, Android 4.2.2
Default browser on Samsung Galaxy S3, Android 4.3
Default browser on HTC M8, Android 4.4.2
Chromium Samsung
Blink; Chromium 28
Default browser on Samsung Galaxy S4, Android 4.4.2
This is Samsung’s Chrome.
Chromium Puffin
Blink 30; apparently
Possibly proxy-ish browser; doesn’t make connection to my internal server, but does do some stuff client-side.
3.7 Free Edition on Samsung Galaxy Note, Android 4.1.2; claims to be Chrome 30
Chromium Cyanogen
Blink; Chromium 33
Default browser on Galaxy Nexus flashed with Cyanogenmod 11, Android 4.4.4
This is Cyanogen’s Chrome.
Chromium Opera
Blink; Chromium 37
24 on LG L5, Android 4.1.2
24 on HTC M8, Android 4.4.2
This is Opera Mobile.
Chromium Google
Blink; Chromium 37
Default browser on Nexus 7, Android 4.4.2
Default browser on Motorola Moto G, Android 4.4.4
This is Google’s regular Chrome. I test it only on devices where it is the default browser.
UC
WebKit 534
UC 9.9.2 on Samsung S3, Android 4.3
UC 9.9.2 on Xiaomi M2, Android 4.1.1
UC 9.9.3 on Huawei C8813, Android 4.1.1
The largest Chinese browser. This is the full variant, not the proxy. These browsers were pre-installed (next to Android WebKit; don’t ask me why).
BlackBerry 6
WebKit 534
Default browser on BB Torch 9800 (OS6)
BlackBerry 7
WebKit 534
Default browser on BB Torch 9810 (OS7)
BlackBerry 10
WebKit 537
Default browser on BlackBerry Z10 (BB OS 10.1)
A new BB10 version has been released, but my device cannot connect to the update server.
This device has 1GB of internal memory instead of the customary 2GB, which may matter in performance tests.
Nokia Xpress
Gecko 20100401; this version was used for some Firefoxes from 3 to 4.
Proxy browser
5.5 on the Nokia Asha 311, S40.
UC Mini
Gecko; don’t know version number
Proxy browser
8.8 on HTC One X, Android 4.2.2
9.4 on Motorola Moto G, Android 4.4.2
9.4 on Wolfgang AT-AS45FW, Android 4.2.2 (see note below)
Opera Mini
Presto
Proxy browser
7.6 on Samsung Galaxy S4, Android 4.4.2
8.0 on BB Torch 9800 (OS6)
8.0.3 on iPad 2, iOS 7.1.2
Opera Classic
Presto
12.10 on Samsung Galaxy Pocket, Android 2.3.6
Nintendo
WebKit 536
Nintendo browser 3.0.3 on Wii U (OS version unfindable)
Supposed to be based on NetFront, which in turn is WebKit-based nowadays.
Dolphin
WebKit 534
Dolphin 11.23 with JetPack on Sony Xperia S, Android 4.1.2.
Independent full browser for Android, as long as you install both Dolphin and the Jetpack extension.
IE9
Trident
Default browser on Nokia Lumia 800, Windows Phone 7.5.
IE10
Trident
Default browser on Nokia Lumia 520, Windows Phone 8.0.
IE11
Trident
Default browser on Nokia Lumia 820, Windows Phone 8.1 “Update”
This is a developer phone. That might matter.

Firefox Android
Gecko 32
32 on LG L5, Android 4.1.2
32 on Samsung Galaxy S4, Android 4.4.2
Firefox OS
Temporarily no tests; waiting for Flame

Wolfgang AT-AS45FW note: Wolfgang is a Dutch importer and re-brander of phones. In this particular case they seem to have bought Chinese (? probably) phones, re-branded them, then re-sold them to the Whoop company, which re-branded them and sold them to the Hema chain of supermarkets, which sells them to consumers as the Whoop Echo. Supply chain management FTW!