One of the lesser known tricks with CSS is the fact that you don't have
to limit your elements to just one class. If you need to set multiple
classes on an element, you add them simply by separating them with a
space in your attribute. For example: let's assume
we have two custom classes in the style sheet named
Standards based
browsers allow you to apply two or more classes to an element!
maintext
and
center
respectively:.maintext {
font-family: "Courier New", Courier, mono;
font-size: 14px;
color: #FFCC99
}
.center {
text-align: center;
}
Then what we could do is apply both classes to the same element with the
following syntax:<div id="Layer2" class="maintext center">
So if we specify the font-size in both the classes which one will it pick up overriding the other? For example if we write
ReplyDelete.maintext {
font-family: ""Courier New", Courier, mono;
font-size:12px;
}
.center {
text align: center;
font-size:9px;
}
which font size would it consider out of the two classes and which one would it override?
Font Size of first class will get override by second class.
DeleteFor eg:
if you write class="maintext center" than final font size will be 9px.
if you write class="center maintext" than final font size will be 12px.
I hope i have solved your question.
Let me know if you have any other concerns.
Thanks.