In this tutorial, we will learn about id in HTML with the help of examples.
The id attribute is used to specify a unique id for an element in an HTML document.
We cannot use more than one element with the same id in an HTML document.
The value of the id attribute must be unique within the HTML document.
Using Id Attribute
An Id name can be defined within the <style> element, or in the external CSS file.
The id name is case sensitive.
To create a id, write a hash # character followed by a id name.
color : blue;
color : green;
<p id = "cricket">This is a paragraph with cricket id.</p>
<p id = "football">This is a paragraph with football id.</p>
This is a paragraph with cricket id.
This is a paragraph with football id.
We hope that this tutorial helped you develop better understanding of the concept of id in HTML.
Keep Learning : )
In the next tutorial, you'll learn about HTML