Text (W3C DOM Core object)

Version Depr. Parent
DOM1 No CharacterData
Browser support (more…)
IE5.5+ FF1.5+ SA1.3+ OP9+
Partial Full Full Full


<p>He pumps funk in the cracks and cuts wax with an axe</p>

The example above shows a paragraph containing a single Text node, with the nodeValue He pumps funk in the cracks and cuts wax with an axe.


The Text interface inherits from CharacterData, and represents the text content (referred to as character data) inside an Element or Attr node.

When a document is first loaded there will be only one Text node for each block of text. Operations such as splitText may divide blocks of text into multiple sibling Text nodes, as may creating and adding new Text nodes, but such divisions will not persist between sessions. The normalize method merges adjacent nodes to [re]create the load state of a single Text node for each block of text.

A Text node cannot have children.

Note: Size limits of Text nodes

The DOM does not define a size limit for the data in a Text node, however some implementations do:

4K (4096 bytes)
Opera 9.0
32K (32768 bytes)
Safari 3
64K (65536 bytes)

This has a crucial effect on the ability to process and manipulate text, because browsers can only work with data up to their limit. The data and nodeValue of a Text node will only include that much data, and methods such as cloneNode will only be able to clone up to that limit.

Furthermore, there is no way to retrieve the additional data in browsers that do have a limit. The DOM specification suggests to use the substringData method to do this, implying that the data is there but unreadable; however this is not the case — as far as the browser is concerned, there is no more data.


Internet Explorer Firefox Safari Opera
5.5 6.0 7.0 1.5 2.0 3.0 1.3 2.0 3.0 9.0 9.5
Partial Partial Partial Full Full Full Full Full Full Full Full

Internet Explorer 6 and 7 don't inherit the normalize method from Node.

In this Section

User-contributed notes

There are no comments yet.

Related Products