The id Selector

The id Selector

//the style rule below will be applied to the HTML element with id="para1"

#para1 {
  text-align: center;
  color: red;
}
  • Uses the id attribute of an HTML element to select a specific element.
  • The id of an element should be unique within a page, so the id selector is used to select one unique element!.
  • To select an element with a specific id, write a hash (#) character, followed by the id of the element.
  • An id name cannot start with a number.

Related concepts

The id Selector

The id Selector — Structure map

Clickable & Draggable!

The id Selector — Related pages: