Classes in CSS
We can use multiple classes for an element, i have a doubt is there any limitation for the count?
<div class="class1 class2 class3 ..... "></div>
How many classes can be used for an element?
Share Your Ideas....
No idea. I thought you could just use as many as you wanted.
Can anyone Confirm..
I think there is a limitation, if anyone knows please specify..
No limitation, -so long as no declaration/selector over-rules another, previously-stated. Then, order-of-precidence takes 'hold and the last-stated is the obeyed.
would be GREEN text, because the class "third" is stated last in the precedence order in the HTML..
<h1 class="first second third
It gets complicated when you want some styles from class="first" and class="second" if you need "display:block;" and the second class states "display:inline;", and so forth...
Myself, if more than TWO classes are needed, I combine the stated-needed Declarations and create another new class (like, class="four") and use solely that, instead of combining three potentially-conflicting classes.
I build for: Firefox and tweak for IE
Within the confines of the syntax of HTML a class is just an attribute and I've never seen a character limit on an attribute value. If there are limits they are probably browser specific.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)