+ 1
Difference between id and class
I am learning CSS.I want to know the the difference between id and class. i .e., when to use id and when to use class.
3 Respostas
+ 1
İ think İD is for one specific tag and class is for one or more tags. A tag can also have multiple classes like: <a class="marine sky important"> wich can be useful for css styling
+ 1
Hello Charan Kumar Reddy.
The main difference is that the Id must be unique. Only one element can have the Id name you chose for it.
The class selector can be applied to several elements.
For example you have like 5 paragraphs and you want to style only 3 of them, use the same class selector for these three and style it on your stylesheet. With an id name you can only style one paragraph.
Usually don't use Id selectors to style your text. Better keep it for script once you'll be familiar with Javascript.
0
thanks