Clarity and Structure with ids

There are a number of attributes that are valid for every element. The first that we will discuss is technically called the “Global Attribute,” however, we will refer to it as the ‘ID’ attribute.

stacked building blocks with different id names

Following from the idea of identification labels, the 'ID' attribute takes as its value a string, which should be a "unique identifier" to that specific element; as in, the ID given to one element should be different from every other element's ID on a page.

To declare the 'ID' attribute of an element, use the standard key="value" syntax for HTML elements.

HTML
<div id="a-unique-id">

<div id="another-unique-id">

You should get in the habit of adding ID attributes to any important HTML elements or elements that you may want to style independently. The ID attribute is one of the ways that we will select elements via CSS to dictate the style and look of our webpages.