Using The id Attribute
id attribute specifies a unique id for an HTML element (the value must be unique within the HTML document).
In CSS, to select an element with a specific id, write a hash (#) character, followed by the id of the element:
Use CSS to style an element with the id “myHeader”:
Tip: The id attribute can be used on any HTML element.
Note: The id value is case-sensitive.
Note: The id value must contain at least one character, and must not contain whitespace (spaces, tabs, etc.).
Difference Between Class and ID
An HTML element can only have one unique id that belongs to that single element, while a class name can be used by multiple elements:
<!– A unique element –>
My Cities<!– Multiple similar elements –>
London is the capital of England.
Paris is the capital of France.
Tokyo is the capital of Japan.
Bookmarks with ID and Links
HTML bookmarks are used to allow readers to jump to specific parts of a Web page.
Bookmarks can be useful if your webpage is very long.
To make a bookmark, you must first create the bookmark, and then add a link to it.
When the link is clicked, the page will scroll to the location with the bookmark.
First, create a bookmark with the
Then, add a link to the bookmark (“Jump to Chapter 4”), from within the same page:
Or, add a link to the bookmark (“Jump to Chapter 4”), from another page:
Leave A Comment