+ 3
What is the diffrens bettwen getting style in css by id and by class
7 Answers
+ 8
Thare is no difference when using them
For example if you have an id on on a paragraph <p> called âtext1â and a class on the same tag called âtext2â there will be no difference
However the only difference is the way you call them:
For id: Use - #
#text1 {
}
For class: Use - .
.text2 {
}
Note - idâs are unique, therefore
can only be used once in
html element.
- classes can be used as
many times as you wish on
an element
+ 3
thanks:3
0
Also, the styling by ID will replace the styling by class, if there are any clashes -- the most specific selector is chosen.
0
Classes can be shared used as many times as you need while ids are unique and can be used only once.
Class and ID are kind of self-explanatory keywords.
0
https://code.sololearn.com/W7sflPVjJY8z/?ref=app
they realy are same:3 no repeats
0
https://www.sololearn.com/Discuss/1425768/?ref=app
Hope this helps âșïžâșïž.
0
Briefly, id style used for one unique item only, where the class style can be used many times as you like (reusability).