CSS allows us to define our own custom selectors also, which is known as ID and class selectors. IDs and classes are applied to (X)HTML elements as simple attributes that provide much tighter control over our design. Most of the time, we get confused IDs with classes, either failing to utilize the real purpose of each or simply using one instead of the other.
Let’s treat ID as identification, which is unique to you an is not shared with anyone else. A class is different, in that there can be many people in a class, be it at school, in society, or wherever. This translates to CSS where an ID can only be used once per page, whereas classescan be used an unlimited number of times.
Another Example could be Bar Code (class) and Serial Number (ID).