In this section, we will learn what the id attribute is and how to use it in HTML.
id Attribute in HTML: Definition and Usage
The `id` attribute is a way of uniquely identifying an element in an HTML document.
Note: the value we set for an id attribute should be unique in that HTML document. Meaning only one HTML element can have that value for its id attribute.
HTML id Attribute Syntax
<element id = “value”>
HTML id Attribute Values
The value set for the id attribute could be any general or specific names. But it’s better to always endeavor for names that specifically describe the element it applied to.
Example: div with id
In this example, we’ve used the id value of the <div> element in CSS to apply a style to it.