Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM createTextNode() Method

  • Difficulty Level : Basic
  • Last Updated : 19 Apr, 2021
Geek Week

The createTextNode() method is used to create a TextNode which contains element node and a text node. It is used to provide text to an element. This method contains the text values as parameter which is of string type.

document.createTextNode( text )

Parameters: This method accepts single parameter text which is mandatory. It is used to specify the text of text node.


<!DOCTYPE html>
        <title>DOM createTextNode() Method</title>
            h1, h2 {
            body {
        <h2>DOM createTextNode() Method</h2>
        <button onclick="geeks()">Submit</button>
            function geeks() {
                var x =


Before Clicking on Button:

After Clicking on Button:

Supported Browsers: The browser supported by DOM createTextNode() Method  are listed below: 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :