querySelector()

Returns the first element within the document that matches the specified CSS selector.

Syntax

javascript
document.querySelector(selector)

Example

javascript
const nav = document.querySelector("nav");
const btn = document.querySelector(".btn-primary");
const hero = document.querySelector("#hero");