But why They use id and class? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

But why They use id and class?

22nd Jul 2016, 8:47 AM
Arthur Brüninghaus
Arthur Brüninghaus - avatar
4 Answers
+ 2
We can assign more than one element with same class but we can assign only one element with same I'd name. We can style more than one element like div, p, he, footer etc combinely with giving them same class
22nd Jul 2016, 1:31 PM
Shubham Gupta
Shubham Gupta - avatar
0
It's so that we could assign styles to different elements under the same tag name. For eg. <p id="one">one</p> <p class="two">two</p> Here both have same tag i.e <p> but both can have different styles using the id and class name
22nd Jul 2016, 9:19 AM
PUNEET SINGH
PUNEET SINGH - avatar
0
ok
22nd Jul 2016, 9:38 AM
Arthur Brüninghaus
Arthur Brüninghaus - avatar
0
for example if I'd like the first letter of the first paragraph of a page to be larger I would use an id and if I want every other paragraph to have a light grey background I'd use a class.
23rd Jul 2016, 7:11 PM
Derek Venuto
Derek Venuto - avatar