Multiple CSS Classes

I'm not sure I should really admit to not knowing this... but today was the first time I'd realised that the "class" attribute for elements within a HTML document can accept more than one class name. doh.

Update: Here's a simple example. With the following in your style sheet...

.align-c { text-align: center; }
.font-b { font-weight: bold; }


You can have something like <div class="align-c font-b"></div> to make the contents of the div tag bold and centre-aligned.
Published 17 November 2005 02:10 PM by James Crowley

Comments

# Sri said on 17 November, 2005 09:39 AM
Cool! I didn't know that. Could you post an example?
# Alex said on 17 November, 2005 09:55 AM
http://www.w3.org/QA/Tips/goodclassnames
# James Crowley said on 17 November, 2005 10:09 AM
hehe - point taken. It was only an example ;-)
# J.R. said on 18 November, 2005 08:16 AM
Dont' worry I found that out a couple months ago. I don't think it's common knowledge but it's nice to know. :)
# Daniel said on 21 November, 2005 06:17 AM
Same here. I only found this out a couple of months ago as well. Can't believe I didn't know it.
# mark said on 22 August, 2007 01:51 PM

well I didn't know that

Leave a Comment

(required) 
(required) 
(optional)
(required)