Home » Web Design and Development » HTML » HTML Id Attribute

HTML Id Attribute

HTML Id attributes starts with hash ( # ) in CSS. We can use this attribute to style any element in html.

Below is the simple example of using “id” attribute for styling paragraph.

<!DOCTYPE html>

#exampleId1 {
  background-color: red;


<p id="exampleId1">Para1 - This paragraph is styled with id "exampleId1"</p>


When we run this code in browser, we can see the page as,


You can also see another post “Difference between an Id and Class in HTML”

Leave a Comment