Skip to main content

Search

Navigation

Sponsor: The CSS Anthology

Blog Entry

Working With Two Classes

Published on the 29th of October 2005

By Ethan Poole

It is very easy to assign an element two classes, as mentioned in the Lowter article, Four Quick CSS Tips. Another neat little tip is assigning styles to an element as long as it belongs to two specific classes.

First, assign the element two classes:

XHTML
<div class="one two">...</div>

Then, use the following CSS to apply styling to an element of both classes:

CSS
div.one.two {
    ...
}

These styles will only be applied to an element that is assigned both classes, one and two in this case. You can also use this method for three, four, etc. classes too. I have found this very useful in quite a few situations.

Comments

Sponsor: Songbird Media Player

Applications

Categories

Use Opera

Opera 9. Innovation delivered. Download Now (external link)

Archives

Author Profile

Ethan Poole

Ethan is a PHP developer from the sunny state of Florida. He is the Managing Director of Lowter, directing and overseeing all production. Ethan is a crazy fan of the Opera (external link) web browser and he enjoys foreign language.

All Articles by Ethan

Additional Navigation

Copyright © 2004-2008 Lowter

Sponsor Links