CSS ID
An id is a unique identifier you add to a single HTML element with the id attribute, then target in CSS with a hash, like #header. Each id should appear only once per page.
Web
Because ids are unique, they are useful for one-off elements and as anchor targets for in-page links (href="#section"). JavaScript also uses them with getElementById().
Ids have high specificity, which can make styles hard to override, so many developers prefer classes for general styling and reserve ids for unique hooks.
Examples
HTML
<div id="header">Site Title</div>Output:
Marks the div as the unique element with id 'header'.CSS
#header {
background: black;
color: white;
}Output:
Styles the single element with id 'header' with a black background and white text.