id identifier
The id
attribute is used to
give an element a specific and unique name in the document. In the
earlier div
example, id
was used to label a section of the page
as “sidebar.” That means there may be no other element with id="sidebar"
in that document (although, it
is okay if it appears in other documents on the same site). ID values
must be unique.
The HTML 4.01 Recommendation specifies the following uses for
id
attribute:
As a style sheet selector
As a target anchor for links (with the same functionality as
<a name="">
)As a means to access an element from a script
As the name of a declared object element
For general purpose processing by user agents, essentially treating the element as data
Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.