Subscribe to RSS

Using multiple CSS styles on a single element

I have been asked questions recently about using different sets of styles on elements and thought I would briefly touch on the subject to explain a little further. Have you ever wanted to use styleA and styleB on the same div? Well with classes you can, you can easily specify multiple classes on what div or any element that you want without any trouble at all.This isn’t explicitly stated in some help sites and can be easily overlooked because it is not often that you can do this kind of thing within HTML and CSS. You will see below what I mean if it is still unclear what I am talking about.


<div class="styleA styleB">
</div>

Nothing particularly fancy but can come in very handy if you have several different objects that are only styled slightly different but you want to write less CSS. You can use as many classes on any type of element as you need. There isn’t a limitation of any kind on such things.

Popularity: 3%

Whats Next?

  • Save to Delicious! Save the page

4 Responses to “Using multiple CSS styles on a single element”

  1. Mark Abucayon Says:

    whew awesome- additional information again. great job. Thanks

  2. Bobby Says:

    Nice, easy CSS article. Love the site!

  3. Jared Says:

    I don’t think you mentioned that you can also apply an id to those elements as well as multiple CSS classes.

  4. Ian Says:

    Great css 101 article, definitely something for beginners to be aware of— it can save a ton of time!

Leave a Reply


Recent comments

I’ve been on a vacation, normality will happen next week

On August 28, 2008, holiday travel wrote:

well this is useful… (at least for me) very thanks ————&# 8212;———R 12;—–...

Top 10 search engine optimization techniques

On August 26, 2008, ибп wrote:

А что, неплохо!

Styling the first post of your Wordpress blog

On August 21, 2008, cheap website design wrote:

good point you have in there! thanks for sharing with us

CSS Hack:Getting Safari to behave

On August 21, 2008, Glass wrote:

You can also target Safari with the following: body:first-of-type .class {} That is: just prepend css the rule with body:first-of-type. Simple.

Styling the first post of your Wordpress blog

On August 20, 2008, jeeremie wrote:

Hi, This solution didn’t work for me. Instead, I use this one »