HTML DOM querySelectorAll() Method Last Updated : 16 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The querySelectorAll() method in HTML is used to return a collection of an element's child elements that match a specified CSS selector(s), as a static NodeList object. The NodeList object represents a collection of nodes. The nodes can be accessed by index numbers. The index starts at 0. Note: If we want to apply CSS property to all the child nodes that match the specified selector, then we can just iterate through all nodes and apply that particular property. Syntax: element.querySelectorAll(selectors) Selectors are the required field. It specifies one or more CSS selectors to match the element. These selectors are used to select HTML elements based on their id, classes, types, etc. In the case of multiple selectors, a comma is used to separate each selector. Example: In this example, we will use querySelectorAll() method HTML <!DOCTYPE html> <html> <head> <title>DOM querySelectorAll() Method</title> <style> #geek { border: 1px solid black; margin: 5px; } </style> </head> <body style="text-align: center;"> <h1 style="color: green;">GeeksforGeeks</h1> <h2>querySelectorAll() Method</h2> <div id="geek"> <p>This is paragraph 1.</p> <p>This is paragraph 2.</p> </div> <button onclick="myFunction()">Try it</button> <script> function myFunction() { let x = document.getElementById("geek") .querySelectorAll("p"); let i; for (i = 0; i < x.length; i++) { x[i].style.backgroundColor = "green"; x[i].style.color = "white"; } } </script> </body> </html> Output: Supported Browsers: The browser supported by the querySelectorAll() method are listed below: Apple Safari 3.1Google Chrome 1.0Edge 12.0Firefox 3.5Opera 10.0Internet Explorer 9.0 Comment More infoAdvertise with us V Vishal Chaudhary 2 Follow Improve Article Tags : Web Technologies HTML Web technologies HTML-DOM Similar Reads HTML DOM links Collection The DOM links collection is used to return the collection of all <a> and <area> elements with the "href" attribute in the HTML document. The elements in the collection are sorted as they appear in the sourcecode. Syntax: document.links Properties: It contains a single property length whi 4 min read HTML DOM open() Method The DOM Open() method in HTML is the combination of the following three steps: Opens an output stream to collect the output.Collects output from the document.write() or document.writeln() methods.Runs the document.close to display the output written to the output stream. Syntax: document.open( MIMEt 2 min read HTML DOM designMode Property The DOM designMode property in HTML is used to specify whether the document is editable or not. It can also be used to set the document editable. Syntax:Set: This property is used to set whether the document is editable or not.document.designMode = "on|off";Get: This property is used to return wheth 2 min read HTML DOM Style borderCollapse Property The DOM Style borderCollapse property in HTML is used to set or return whether the border of the table collapsed into a single border or not. Syntax: It is used to return the borderCollapse property.object.style.borderCollapse It is used to set borderCollapse property.object.style.borderCollapse = " 2 min read HTML DOM Style borderBottom Property The DOM style borderBottom property is used to set or return the three different border-bottom properties such as border-bottom-width, border-bottom-style, and border-bottom-color of an element. Syntax: It returns the borderBottom Property.object.style.borderBottomIt is used to set the borderBottom 2 min read HTML DOM Style color Property The DOM style color property is used to set or return the color of the text. Syntax: It is used to set the color property.object.style.colorIt is used to return the color property.object.style.color = "color|initial|inherit" Return Values: It returns a string value that represents a text-color of an 1 min read HTML DOM cookie Property Almost every website stores cookies (small text files) on the user's computer for recognition and to keep track of his preferences. DOM cookie property sets or gets all the key/value pairs of cookies associated with the current document.Getting all the Cookies: The document.cookie method returns a s 3 min read HTML DOM isId Property The isId Property contains a boolean value that returns a true if the Element has an attribute type of ID, otherwise, it returns a false or undefined value. This Property is used for read-only. Syntax: attribute.isId Return Value: It returns a Boolean value i.e. true if the attribute type is ID, els 2 min read HTML DOM createElement() Method In an HTML document, the document.createElement() is a method used to create the HTML element. The element specified using elementName is created or an unknown HTML element is created if the specified elementName is not recognized. Syntaxlet element = document.createElement("elementName");In the abo 2 min read HTML DOM hasFocus() Method In HTML document, the document.hasfocus() the method is used for indicating whether an element or document has the focus or not. The function returns a true value if the element is focused otherwise false is returned. This method can be used to determine whether the active element is currently in fo 2 min read Like