Student-friendly HTML, CSS, and JavaScript reference with examples
Finds the first element that matches a CSS selector.
const button = document.querySelector('button');
const box = document.querySelector('.box');
const header = document.querySelector('#header');
Returns the element if found, or null if no match exists.