ID, at the present time it's an identity of a person or thing or a digital product. But In html5 id have an attitude who used to set a unique name for a tag in a web document. Give a name to element is important for it with a style sheet, a web link or a scripting language. When give value to id, that important, it's beginning with a letter (A-Z or A-Z) and may be followed by any number of letter, digits, hyphen or period.
It's value not contain whitespace that must same time user not understand how the class and id different, so a class can be used by multiple element and give two or more value in one class name but id attitude only be used by one element with only one value in one webpage. It's case sensitive it means Kingdom and kingdom have two different id value.
Syntax :
<tag id="value">content</tag>
Note: In this following example, we give id name "main" to the <div> element.
Important :
ID Attribute Use In CSS As Selector :
The id attribute make easy to give style and color in html elements. A user can access an element directly by its id name. Using a id value name for styling in CSS, first write a hash character (#) and second write an id value (example: #value). Then define the CSS properties under curly braces {}.
ID Attribute Use In JavaScript :
In scripting language, it's purpose is to identify the HTML element when given a command or manipulate text. JavaScript can access an element to its id with the DOM (Document Object Model) method getElementsById().