dojoX dojoX - 1 year ago 57
CSS Question

How to apply two CSS classes to a single div/span

Can i apply 2 classes to a single div or span or any html element? For example:

<a class="c1" class="c2">aa</a>

I tried and in my case c2 does not get applied. How can i apply both classes at once?

Answer Source

1) Use multiple classes inside the class attribute, separated by whitespace (ref):

<a class="c1 c2">aa</a>

2) To target elements that contain all of the specified classes, use this CSS selector (no space) (ref):

.c1.c2 {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download