multiple css classes

Thursday 7th June 2007 03:16 PM

TAGS: css
Perhaps I missed something along the way - but I recently I discovered that you can apply multiple CSS classes to an element and "combine" them.

For example.

.normal_box      { border: 1px solid #CCCCCC; padding: 20px; }
.small_text      { font-family: 9px; }
.red_text        { color: red; }

<div class="normal_box small_text red_text">
  Some small red text!
</div>

It might not immediately seem useful - but it is great when you want to set up some "base" styles and re-use them for multiple elements without repeating the same thing over and over. A nifty little trick is using it for "on" and "off" states for buttons, etc - you can simple have something like class="button on".

Anyway, just thought I would mention it, as I must admit that it is news to me.

Comments on this article:


I love feedback and comments, be the first!

Add Comment:


Make a Comment

*Nb, all comments are moderated to prevent spam or inappropriate content.








netforge logo
netforge provides high quality and friendly website design services to business. We're Australian based and reliable... (find out more).