document.querySelector() vs document.querySelectorAll()
document.querySelector() and document.querySelectorAll() are both JavaScript DOM APIs, and choosing between them is a common point of confusion. This page compares their syntax, parameters, return values, and typical use cases so you can pick the right one. document.querySelector(): Returns the first matching element. Its syntax is document.querySelector(selectors). document.querySelectorAll(): Returns all matching elements as a NodeList. Its syntax is document.querySelectorAll(selectors). Example of document.querySelector(): document.querySelector(".my-class"). Example of document.querySelectorAll(): document.querySelectorAll("div"). Read the full references for document.querySelector() and document.querySelectorAll() to see edge cases, time complexity, browser support, and the mistakes developers most often make with each. Other DOM APIs worth comparing: document.getElementById(), element.addEventListener(), element.removeEventListener(), document.createElement(), element.appendChild(), element.removeChild(). Both belong to the DOM category in the JS Reference documentation, which covers 494 entries in total. Try both in the JavaScript playground to see the behavioral difference live.