Can there be several classes with one tag in html? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can there be several classes with one tag in html?

1st Sep 2017, 7:56 PM
Onyinyechuqu Obiorah
3 Answers
+ 2
okay, thanks alot!
1st Sep 2017, 8:18 PM
Onyinyechuqu Obiorah
+ 2
A tag can have multiple classes but only one 'class' attribute. (this is true for any attribute) So you can have <a class='class1 class2'>text</a> and rules for both class1 and class2 will apply. Class names are separated by spaces. But <a class='class1' class='class2'>text</a> is incorrect. Only one attribute will be recognized.
1st Sep 2017, 9:25 PM
Hans Holler
Hans Holler - avatar
+ 1
I mean <p class="italic" class="size">content </p>
1st Sep 2017, 8:05 PM
Onyinyechuqu Obiorah