querySelector
querySelector is a DOM method that returns the first element within the document (or within a specified element) that matches a given CSS selector. It is available as document.querySelector and Element.querySelector, and returns null if no element matches.
The method accepts a single string containing a CSS selector. It can locate elements by id, class,
To obtain all matches, use querySelectorAll, which returns a static NodeList of elements. Unlike querySelector, it
querySelector can be used on the document object or any Element, enabling scoped searches within a subsection
Performance and compatibility: querySelector is widely supported in modern browsers, including older versions of Internet Explorer.