A class, like the name states, is a classifier.
This means that a class is able to style a group of HTML elements.
With class selectors, you can have many within an HTML element and many throughout the HTML sheet.
In CSS, class is represented with a period then the class name.
Here is an example of class written in CSS:
An id is a unique identifier. It is used to style a single element within HTML. It can only be used once within an HTML sheet.
Think of id as your fingerprint. It is unique to you, and (in most cases) cannot be used by anyone else.
In CSS an id is represented with a # then followed with the id name.
Here is an example of id written in CSS:
It is important to note that because ids are super specific and special. They will always override a class selector.
You can use class when you are wanting to group related styles together.
For example, all the subheadings on your website will be styled the same way.
An id should be used when you are wanting to style one element specifically.
For example, you wish to create a round border on a specific photo.