This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The CharacterData abstract interface represents a Node object that contains characters. This is an abstract interface, meaning there aren't any objects of type CharacterData: it is implemented by other interfaces like Text, Comment, CDATASection, or ProcessingInstruction, which aren't abstract.
This interface also inherits properties from its parents, Node and EventTarget.
CharacterData.dataA string representing the textual data contained in this object.
CharacterData.length Read only
Returns a number representing the size of the string contained in the object.
CharacterData.nextElementSibling Read only
Returns the first Element that follows this node, and is a sibling.
CharacterData.previousElementSibling Read only
Returns the first Element that precedes this node, and is a sibling.
This interface also inherits methods from its parents, Node and EventTarget.
CharacterData.after()Inserts a set of Node objects or strings in the children list of the CharacterData's parent, just after the CharacterData object.
CharacterData.appendData()Appends the given string to the CharacterData.data string; when this method returns, data contains the concatenated string.
CharacterData.before()Inserts a set of Node objects or strings in the children list of the CharacterData's parent, just before the CharacterData object.
CharacterData.deleteData()Removes the specified amount of characters, starting at the specified offset, from the CharacterData.data string; when this method returns, data contains the shortened string.
CharacterData.insertData()Inserts the specified characters, at the specified offset, in the CharacterData.data string; when this method returns, data contains the modified string.
CharacterData.remove()Removes the object from its parent children list.
CharacterData.replaceData()Replaces the specified amount of characters, starting at the specified offset, with the specified string; when this method returns, data contains the modified string.
CharacterData.replaceWith()Replaces the characters in the children list of its parent with a set of Node objects or strings.
CharacterData.substringData()Returns a string containing the part of CharacterData.data of the specified length and starting at the specified offset.
| Specification |
|---|
| DOM> # interface-characterdata> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
CharacterData |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
after |
54 | 17 | 49 | 39 | 10 | 54 | 49 | 41 | 10 | 6.0 | 54 | 10 |
appendData |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
before |
54 | 17 | 49 | 39 | 10 | 54 | 49 | 41 | 10 | 6.0 | 54 | 10 |
data |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
deleteData |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
insertData |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
length |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
nextElementSibling |
29 | 17 | 25 | 16 | 9 | 29 | 25 | 16 | 9 | 2.0 | 4.4 | 9 |
previousElementSibling |
29 | 17 | 25 | 16 | 9 | 29 | 25 | 16 | 9 | 2.0 | 4.4 | 9 |
remove |
24 | 12 | 23 | 15 | 7 | 25 | 23 | 14 | 7 | 1.5 | 4.4 | 7 |
replaceData |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
replaceWith |
54 | 17 | 49 | 39 | 10 | 54 | 49 | 41 | 10 | 6.0 | 54 | 10 |
substringData |
1 | 12 | 1 | ≤12.1 | 1 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
Text, CDATASection, ProcessingInstruction, and Comment.
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CharacterData