document.querySelector() takes a CSS selector and returns a single element.".class" matches elements by class name. When several elements share the class, querySelector returns only the first match in document order.querySelectorAll(), which returns a NodeList. querySelector never throws for multiple matches and does not require an ID.