HTML · HTML Tutorial · Lesson 23
HTML Id
Unique ids for single elements.
The id attribute specifies a unique id for an element. It must be unique within the page.
Example
<style>
#myHeader { background-color: lightblue; color: black; padding: 40px; text-align: center; }
</style>
<h1 id="myHeader">My Header</h1>
In CSS, select an id with a hash (#) followed by the id name.
Class vs Id
Keep reading “HTML Id”
Sign up to read the full lesson (4 more parts), try every example in the live editor, and take the 5-question quiz.