We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE

Creates a new Text node.


var text = document.createTextNode(data);
  • text is a Text node.
  • data is a string containing the data to be put in the text node.


<!DOCTYPE html>
<html lang="en">
<title>createTextNode example</title>
function addTextNode(text) {
  var newtext = document.createTextNode(text),
      p1 = document.getElementById("p1");


  <button onclick="addTextNode('YES! ');">YES!</button>
  <button onclick="addTextNode('NO! ');">NO!</button>
  <button onclick="addTextNode('WE CAN! ');">WE CAN!</button>

  <hr />

  <p id="p1">First line of paragraph.</p>


Specification Status Comment
Document Object Model (DOM) Level 3 Core Specification
The definition of 'Document.createTextNode()' in that specification.
Obsolete No change
Document Object Model (DOM) Level 2 Core Specification
The definition of 'Document.createTextNode()' in that specification.
Obsolete Initial definition

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes)(Yes) (Yes) (Yes) (Yes) ?
Feature Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ?(Yes) ? ? ? ?

Document Tags and Contributors

 Last updated by: erikadoyle,