Skip to content
Related Articles

Related Articles

HTML | DOM normalizeDocument() Method

View Discussion
Improve Article
Save Article
  • Last Updated : 25 Jul, 2019
View Discussion
Improve Article
Save 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

    My Personal Notes arrow_drop_up
    Recommended Articles
    Page :

    Start Your Coding Journey Now!