HTML Class Attribute:

  • The Class attribute is used to specify a class for html element.
  • Multiple HTML elements can share the same class.
  • Syntax Of Class:To create a class, start with a period (.) followed by the class name. Then, define the CSS properties inside curly braces {}.
  • This is example of class:
#class_name{
background-color:red;
color:white;
}
 <h1 class="class_name">This the example of class attribute</h1>

HTML Id Attribute:

  • The id attribute gives a unique identifier to an HTML element. The id value must be unique within the HTML document.
  • To use an id, start with a hash character (#) followed by the id name. Then, define the CSS properties inside curly braces {}.
  • The id name is case sensitive.
#id_name{
background-color:red;
color:white;
}
<h1 class="id_name">This the example of class attribute</h1>