+ 12
What is the difference between id and class?
understand and know how to use
12 Answers
+ 18
Don't think you could get a link better than this one : https://css-tricks.com/the-difference-between-id-and-class/
+ 10
the classe defines a set of elementi whit common features,with the ID Boeing defined as a unique element .
+ 5
id can only be used once
+ 4
An element can have multiple class but multiple id, id are to differentiate an element from all others
+ 4
still not very clear, need more explanations
perhaps I should come back after visiting link provided by dayve
+ 4
an id is related to only one html element ..so when you apply css styles on that id ..only the specific element will be affected..while class can be used by any element even from different type in order to reduce repetition of code
+ 3
id and class using in css, we using . operator and # operator
+ 2
to me I think id and class are almost the same, both does the same work. but when representing it in the CSS sheet is different the id makes use of "#" at the beginning while class doesn't make use of "#".
for example:
<p class="one">
I am a boy
</p>
one. {
color:blue;
}
<p Id=" two">
I am a boy
</p>
#two {
color:green;
}
+ 1
Id is only for specifying one element whereas class can specify multiple elements.
+ 1
to me I think id and class are almost the same, both does the same work. but when representing it in the CSS sheet is different the id makes use of "#" at the beginning while class doesn't make use of "#".
for example:
<p class="one">
I am a boy
</p>
one. {
color:blue;
}
<p Id=" two">
I am a boy
</p>
#two {
color:green;
}
+ 1
ID can only be used once while class can be used anywhere
0
Id only use one time in one page but we use class many times