Firstly lets talk about Difference between id and class attribute:
The difference is “id” attributes are unique in a page and can only apply to one element, and where as “class” selector can apply to multiple elements.
HTML and CSS go hand in hand. They are the fundermentals behind every webpage. HTML is the skeleton of our page(HTML elements) and CSS is the art side of things.CSS selectors, Class and ID are two of the frequently used selectors.
An ID is used to identify, style & format a singular element.
A Class is a selector used to to define/group/target many elements at once. In CSS they'll be displayed as ".", followed by the name of the class selector. for e.g .color