querySelector document.querySelector(CSS Selector)
querySelectorAll document.querySelectorAll(CSS Selector)
querySelector()
The querySelector() method returns the first Element within the document that matches the specified selector, or group of selectors. It returns only first one code
If no matches are found, null is returned
Example:-
querySelectorAll
The querySelectorAll() method in HTML is used to return the All element that matches a specified CSS selector(s) in the document. The querySelector() method only returns the first element that matches the specified selectors. To return all the matches, use the querySelectorAll() method
Example:-
Output:-