Login
Your Email
Pasword
Home
Write
Trending
History
Liked
Dashboard

What is the id Attribute in HTML?

The id attribute specifies a unique id for an HTML element .

Do you have similar website/ Product?
Show in this page just for only $2 (for a month)
Create an Ad
0/60
0/180
The id value can be used by CSS and JavaScript to perform certain tasks for a unique element with the specified id value.
To select an element in css with a specific id you need to write a hash (#) character followed by the id of the element.
E.g:

My Header


HTML element can only have one unique id that belongs to that single element while a class name can be used by multiple elements.
id Attribute in JavaScript
JavaScript can access an element with a specified id by using the getElementById() method.
E.g: