HTML id attribute

HTML id attribute

In this tutorial, we will learn about id attribute in HTML with the help of examples.

id attribute

The id attribute is used to specify a unique id for an HTML element. The value in id attribute ,must be unique within the HTML document.

Note : We can use id attribute is used in Javscript,stylesheet to target an HTML tag with the specific id.


<a id = "MyId">......</a>

Attribute values

Value Description
id Used to specify a unique id for the element

Id Naming Rules

Naming rules to specify id :

  • Must contaim at least one character
  • Must begin with a letter A-Z or a-z
  • Can be followed by : letters(A-Z, a-z), digit(0-9), hypens("-"), and underscore("_")
  • Must not contain any space characters

Next Tutorial

We hope that this tutorial helped you develop better understanding of the concept of id Attribute in HTML.

Keep Learning : )

In the next tutorial, you'll learn about HTML lang Attribute.

- Related Topics