HTML DOM normalize() Method Last Updated : 16 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The normalize() method in HTML is used to merge the adjacent text nodes with the first text node and flush out the empty nodes. The normalize() method does not require any parameter. Syntax: node.normalize() Example 1: In this example, we will use normalize() method. HTML <!DOCTYPE html> <html> <head> <title> DOM normalize Method </title> </head> <body onload="normalizeNode()" style="text-align:center"> <h1>GeeksforGeeks</h1> <h2>DOM normalize() Method</h2> <button onclick="normalizeNode()"> Normalize </button> <button onclick="addNode()"> Add node </button> <p>There are <span id="count"></span> child nodes.</p> <script> // onload is used to reset the child text nodes // count when page is refreshed and addNode // function is used for addNode button function addNode() { // Creating a text node named "Normalize" let textNode = document.createTextNode("Normalize "); // Using variable text_body to //access the whole body let text_body = document.body; // Adding text node to the end of the body text_body.appendChild(textNode); // Count is used to store number of child text // nodes present in the document let text_node = document.getElementById("count"); // innerHTML fetches value of text_node and // update it with new value. text_node.innerHTML = text_body.childNodes.length; } // normalizeNode function is used to Normalize button function normalizeNode() { document.normalize(); let text_body = document.body; let node_count = document.getElementById("count"); node_count.innerHTML = text_body.childNodes.length; } </script> </body> </html> Output: Supported Browsers: The browser supported by DOM normalize() Method are listed below: Google Chrome 1 and aboveEdge 12 and aboveInternet Explorer 9 and aboveFirefox 1 and aboveOpera 12.1 and aboveSafari 1 and above Comment More infoAdvertise with us A abhishek7 Follow Improve Article Tags : Web Technologies HTML Web technologies HTML-DOM Similar Reads HTML DOM setNamedItem() Method The setNamedItem() method is used to add a particular node to an attribute node using its name. These attribute nodes are collectively called as namedNodeMap. It can be accessed through a name. If a node is already present in the document, it will replace it and return the updated value. The setName 2 min read HTML DOM scripts Collection The DOM scripts Collection in HTML is used to return the collection of all <script> elements in an HTML document. The script elements are sorted as appear in the sourcecode. Syntax: document.scripts Property Value: It returns the single value length which is the collection of all script eleme 2 min read HTML DOM getElementsByName() Method The getElementsByName() method returns collection of all elements of particular document by name. This collection is called node list and each element of the node list can be visited with the help of the index. Syntax: document.getElementsByName(name) Parameter:This function accepts name of document 2 min read HTML DOM getElementById() Method The getElementById() method returns the elements that have given an ID which is passed to the function. This function is a widely used HTML DOM method in web designing to change the value of any particular element or get a particular element. If the passed ID to the function does not exist then it r 3 min read HTML DOM getElementsByClassName() Method The getElementsByClassName() method in Javascript returns an object containing all the elements with the specified class names in the document as objects. Each element in the returned object can be accessed by its index. The index value will start with 0. This method can be called upon by any indivi 3 min read HTML DOM defaultView Property The DOM defaultView property in HTML is used to return the document Window Object. The window object is the open windows in the browser. Syntax:document.defaultView Return Value: It is used to return the current Window Object. Example 1: In this example use the defaultView property to get the window 2 min read HTML DOM forms Collection The DOM forms collection is used to return the collection of all <form> elements in a HTML document. The form elements are sorted as they appear in the source code. Syntax: document.forms Properties: It returns the number of form in the collection of elements. Methods: The DOM forms collection 4 min read HTML DOM referrer Property The DOM referrer property in HTML is used to return the URI of the page that linked to the current page. If the user navigates to the page directly or through a bookmark, then this value is an empty string. Syntax:document.referrer The below program illustrates the referrer property in HTML: Example 3 min read HTML DOM getNamedItem() Method The DOM getNamedItem() method in HTML is used to return the attribute node from the NamedNodeMap object.Syntax: namednodemap.getNamedItem( nodename )Parameter's Value: This method contains a single parameter nodename which is mandatory. The nodename is returned from the NamedNodeMap object. Return V 2 min read HTML DOM createEvent() Event Method The createEvent() method in HTML creates an event object of the specified type. The created event must be initialized before use. Syntax:document.createEvent(event_type)event_type: It is the required parameter and is used to specify the type of event. There are many types of events which are listed 2 min read Like