contact@codebetter.in 8823075444
9993928766
  • Tutorials Home
  • Contact

What is the difference between class and ID selectors?

Sr.No. Class ID
1. We can apply a class to various elements so that it could be numerous times on a single page. The Id is unique in a page, and we can only apply it to one specific element.
2. The class is assigned to an element and its name starts with "." followed by the name of the class. The name of the Id starts with the "#" symbol followed by a unique id name.
3. We can attach multiple class selectors to an element. We can attach only one ID selector to an element.
4. Syntax:
.class{
// declarations of CSS
}
Syntax:
.id{
// declarations of CSS
}