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

HTML Id Attribute

[addthis tool="addthis_inline_share_toolbox"]

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>
<html>
<head>
<style>

#exampleId1 {
  background-color: red;
  font-size:20px;
}

</style>
</head>
<body>

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

</body>
</html>

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

HTML Id

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

Leave a Comment