Is it possible to add more than one class in html? Here is what i've tried:
<a href="#" class="class1" class="class2">My Text</a>
Thanks! :)
HTML elements can be assigned multiple classes by listing the classes in the class attribute, with a blank space to separate them.
Yes, it is possible, but you can only declare the class attribute once per HTML element. Just separate the classes you want to apply by a space. If you declare the class attribute more than once, all definitions beyond the first will be ignored, so in your code .
Absolutely, divs can have more than one class and with some Bootstrap components you'll often need to have multiple classes for them to function as you want them to. Applying multiple classes of course is possible outside of bootstrap as well. All you have to do is separate each class with a space.
The HTML id attribute is used to specify a unique id for an HTML element. You cannot have more than one element with the same id in an HTML document.
Yes, it is possible, but you can only declare the class
attribute once per HTML element. Just separate the classes you want to apply by a space.
<a href="#" class="class1 class2">My Text</a>
If you declare the class attribute more than once, all definitions beyond the first will be ignored, so in your code .class2
will not be applied to your link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With