innerText

  • Unsurpported in Firefox
  • Supported in Chrome
  • Supported in Safari
  • Supported in IE
  • Supported in Opera

The property innerText is a non-standard proprietary property introduced by Internet Explorer and then copied by other browsers. It is not part of HTML5 or the WC3 DOM specification. Its aim is to provide a HTML to plain text conversion, as such it is not the same as the textContent property.

Each browser has implemented this property in different ways.

In summary

  • Firefox does not support innerText property
  • Opera does have the innerText property, but its output is completely different to IE and more like the output from the textContent property, but with extra line returns.
  • Chrome and Safari have a more advanced version of the innerText property, which takes into account the effects of CSS display and white-space properties when converting the DOM to plain text. As such they too can produce quite different outputs to the original IE functionality. IE is aware of some CSS properties but does not aways reflow the content like the webkit browsers.

Exported text from body.innerText

Source/Browser File link
The original HTML html5elements.html
Chrome 23.0 chrome-innertext.txt
Safari 6.0.2 safari-innertext.txt
IE 9.0 ie-innertext.txt
Opera 12.11 opera-innertext.txt

The effects of CSS display and white-space properties on the output body.innerText

Source/Browser File link
The original HTML html5css.html
Chrome 23.0 chrome-innertext.txt
Safari 6.0.2 safari-innertext.txt
IE 9.0 ie-innertext.txt
Opera 12.11 opera-innertext.txt

You can use a tool such as quickdiff to compare the text files and find differences in the properties output across browsers

Note: You should exclude text encoding issues and also allow for the fact that text block’s may have been trimmed when the text was copied out of the browsers into these files

Object, method and property compatibility

  Firefox 17.0.1 Chrome 23.0 Safari 6.0.2 IE 9.0 Opera 12.11
innerText No Yes Yes Yes Yes

Notes

I found claims on the web for support for the innerText property in IE 5.5, Opera 8, Chrome 4 and Safari 4 onwards. Support may well be found in earlier versons of these browsers. Firefox has never supported this property.

Useful Links