While styling of HTML, attribute id & class plays main role.
The HTML class attribute is used to specify a class for an HTML element.
The HTML id attribute is used to specify a unique id for an HTML element.
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 to point to a specific style declaration in a styling element.
#
to indicate this css is for id.#p1 { background-color: yellow; } <p id="p1" >Text line with id="p1"</p>
Text line with id="p1"
Text line with no specific id
The class
attribute used to specify a class for an HTML element
Multiple HTML elements can share the same class.
.
to indicate this css is for class..p2 { color: #3f51b5; font-size: 2rem; } <p class="p2" >Text line with class="p2"</p>
Text line with class="p2"