Open In App
Related Articles

HTML DOM normalizeDocument() Method

Improve Article
Save Article
Like Article

The normalizeDocument() method in HTML is used to normalize an HTML document by remove any empty text nodes if exists. After removing the empty nodes, it also merges all of the adjacent nodes present in the document.

For Example, consider the below element:

Element Geeks
    Text node: ""
    Text node: "Hello "
    Text node: "wor"
    Text node: "ld"

The above element after normalization will become “Hello world”.

Note:This method is not supported by any browser, but it works as DOM normalize() Method and Display the output.




  • The normalize() method does not require any parameter.
  • Example:

    <!DOCTYPE html>
        <meta http-equiv="Content-Type" 
         content="text/html; charset=utf-8" />
        <title>GeeksForGeeks | HTML DOM Normalize Method</title>
        <script type="text/javascript">
            var parent = document.createElement("div");
            parent.appendChild(document.createTextNode("Child 1 "));
            parent.appendChild(document.createTextNode("Child 2 "));
            parent.appendChild(document.createTextNode("Child 3"));
            // Here the length of parent's child nodes would be 3, 
            // you can check the same
            // using parent.childNodes.length. 
            alert('Before Normalize : child nodes length: ' + 
            // Now, parent.childNodes.length === 1
            // Content of all 3 childs nodes
            // are in one child node only.
            alert('After Normalize : child nodes length: ' + 


    Output :
    Before Normalize() call:

    After Normalize() call:

    Supported Browsers: The major browsers are not supported by DOM normalizeDocument() Method

    Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

    Last Updated : 13 Jun, 2023
    Like Article
    Save Article
    Similar Reads
    Complete Tutorials