What is the different Between Class and Id in CSS? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the different Between Class and Id in CSS?

?

22nd Sep 2020, 9:33 AM
Dhanesh Roy
Dhanesh Roy - avatar
4 Answers
+ 6
Class can be used multiple times but id is supposed to be used only once
22nd Sep 2020, 10:03 AM
Locus
Locus - avatar
+ 4
One element can be specified by many class but 1 element can't get many ids
22nd Sep 2020, 9:45 AM
Mask Man(What's in a name?)
Mask Man(What's in a name?) - avatar
+ 1
use the searchbar. it was asked a lot here but here's your salad-: Id is unique, so every element has different id. Many elements can have same class name since classes aren't unique, and that helps manipulating collectively just using a single class name, than styling each one of them with different id.
22nd Sep 2020, 9:35 AM
Rellot's screwdriver
Rellot's screwdriver - avatar
0
With ID we can have only one element with that ID on the other hand there can be as my elements with same classes in a html document
25th Sep 2020, 12:17 PM
👑𝕻𝖗𝖔𝖌𝖗𝖆𝖒𝖒𝖊𝖗👑
👑𝕻𝖗𝖔𝖌𝖗𝖆𝖒𝖒𝖊𝖗👑 - avatar