Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

HTML DOM createTextNode() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The createTextNode() method is used to create a TextNode which contains an 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 the text node.

Example: In this example, we will use createTextNode() method


<!DOCTYPE html>
    <title>DOM createTextNode() Method</title>
        h2 {
            color: green;
            font-weight: bold;
    <h2>DOM createTextNode() Method</h2>
    <button onclick="geeks()">Submit</button>
        function geeks() {
            let x =



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

  • Google Chrome 1
  • Edge 12
  • Internet Explorer 5
  • Firefox 1
  • Opera 7
  • Safari 1
My Personal Notes arrow_drop_up
Last Updated : 08 Jun, 2023
Like Article
Save Article
Similar Reads
Related Tutorials