HTML · Global attributes

id

A unique identifier for one element in the document. Used by CSS, labels, anchors and JavaScript.

Syntax
id="unique-name"

Example

Try it

Notes

IDs must be unique. Duplicate IDs break label associations and querySelector.

More in this group

accesskey aria-atomic aria-controls aria-current aria-describedby aria-disabled aria-expanded aria-hidden

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course