HTML DOM length Property Last Updated : 30 Aug, 2024 Comments Improve Suggest changes Like Article Like Report The DOM length property in HTML is used to get the number of items in a NodeList object. A NodeList is a collection of child Nodes. For example, the NodeList of the body will contain all the child nodes in the body i.e. paragraphs, comments, headings, script, etc.Syntax: nodelist.lengthReturn Value: It returns a numeric value that represents the number of nodes in the nodelist. Example: The below program illustrates the DOM length property in HTML: HTML <!DOCTYPE html> <html> <head> <title> DOM Length Property </title> <script> function geeksFunction() { let node_list = document.body.childNodes; let elements = ""; let i; for (i = 0; i < node_list.length; i++) { elements = elements + node_list[i].nodeName + " "; } elements = elements + "<br> Length: " + document.body.childNodes.length; document.getElementById("demo").innerHTML = elements; } </script> </head> <body style="text-align:center"> <h1>GeeksforGeeks</h1> <h2>DOM Length Property</h2> <button onclick="geeksFunction()">Click Here!</button> <p id="demo"></p> </body> </html> Output: Supported Browsers: The browser supported by DOM length property are listed below: Google ChromeEdge FirefoxOperaSafari Comment More infoAdvertise with us A AshwinGoel Follow Improve Article Tags : Web Technologies HTML Web technologies HTML-DOM Similar Reads HTML DOM documentElement Property The DOM documentElement property is used to return the documentElement as an Element Object. It is a read-only property. It returns a <HTML> Element. Syntax:document.documentElement Return Value: It returns the documentElement of the document or an element object. Example: Below program illust 2 min read HTML DOM Style borderLeft Property HTML DOM Style borderLeft property allows manipulation of the left border style of an element via JavaScript. It controls the border's width, style, and color, affecting the element's visual presentation and layout. HTML DOM Style borderLeft Property Syntax:Get the borderLeft Property.object.style.b 2 min read 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 Like