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.

Comments

6 responses to “Multiple CSS Classes”

  1. http:// avatar
    http://

    Cool! I didn”t know that. Could you post an example?

  2. James Crowley avatar

    hehe – point taken. It was only an example 😉

  3. J.R. avatar

    Dont” worry I found that out a couple months ago. I don”t think it”s common knowledge but it”s nice to know. 🙂

  4. http:// avatar
    http://

    Same here. I only found this out a couple of months ago as well. Can”t believe I didn”t know it.

  5. mark avatar

    well I didn”t know that

Leave a Reply to Alex Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.