HTML Tutorial

The language for building web pages.

HTML Id

The HTML id Attribute

The id attribute specifies a unique id for an HTML element. The value of the id attribute must be unique within the HTML document. The id attribute is used by CSS and JavaScript to select and access a specific element.

Rules:

  • Each id must be unique per page
  • Cannot contain spaces
  • CSS selects with #idname
  • JS accesses with document.getElementById()

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics