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

The textContent property provides a way for a developer to extract the text content of a DOM. The functionality does not try to give a textual representation of how a user views the text rendered by a browser, but how the text is embeded into the DOM structure.

As the functionality is part of the W3C DOM specification there is good support across all modern browsers.

Differences between implementation

  • Firefox incorrectly injects the text High GradeMedium Grade for a keygen tag

Exported text from body.textContent

Source/Browser File link
The original HTML html5elements.html
Firefox 17.0.1 firefox-textcontent.txt
Chrome 23.0 chrome-textcontent.txt
Safari 6.0.2 safari-textcontent.txt
IE 9.0 ie-textcontent.txt
Opera 12.11 opera-textcontent.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
textContent Yes Yes Yes Yes Yes


The property textContent was introduced in the DOM Level 3 specification and only gained support in IE9. IE8 and earlier have support for the innerText property, but it's output is very different. I found claims on the web for support of the textContent property in Firefox from version 2, Opera 9, Chrome 4 and Safari 4 onwards. Support may well be found in earlier versons of these browsers.

Useful Links