July 15, 2004

Daily Tip: Multiple CSS Class Selectors

Today I'm feeling a little off. Actually a lot off. So we're going to cover something easy and quick, Multiple HTML Classes on a single element.

What I mean by multiple classes is that you can assign more than one class to an element.

For example, here is our CSS:

.white { color: #fff; }
.darkgrayBG { background-color: #666; }

Okay, two VERY simple CSS declarations, to a black background, and white text.

So here is our HTML code:

<p class="white darkgrayBG"> blah blah blah blah </p>

Okay. This text would have the black background AND the white color assigned. Very useful when creating small, utility classes that you can mix and match on the fly.

Post Info

Tagged As CSS

Comments are Open (2)

Posted at 07:33 AM

Comments

David Dorward

To nitpick: There is no such thing as a 'CSS class', only a 'CSS class selector'. This is an example of using multiple HTML classes.

Tony

You are right. That is nitpicking.

But yes, there are no CSS Classes. There are HTML Classes, and CSS Class Selectors. W3C specs state it clearest. I'm just lazy, and don't like to type out selector.

I figured people would get the gist of what I was trying to state. But I guess being fully correct is a good thing to be.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Search
Comments on this post
Categories
Info
Tony Stephens
Copyright © 1995-2005
Site Version:
10
Licensed:
Creative Commons
Validate:
XHTML, CSS, 508, RSS
Subscribe
Blog-Fu, Link-Fu