7

I am starting up a brand new web project and would like to know if I can safely use multiple CSS classes nowadays.

<div class="float-left bold bordered"></div>

Do most common browsers support this, or will a significant percentage of my visitors run into major trouble viewing the page?

I'm not worried about special cases like Netscape 1.0 users, but browsers and versions usually used in companies these days.

magnattic
  • 12,638
  • 13
  • 62
  • 115
  • I'd really like to know how you thought of this question :) - if an element could only support one class you think anyone would use CSS?? It'd be a severe limitation! Open Gmail and see the source, for example and you'll see how many classes an element may have :) – PhD Aug 08 '11 at 14:16
  • As far as I know using multiple classes was part of HTML/CSS since the very beginning (i.e. since CSS 1.0 was introduced). – Joachim Sauer Aug 08 '11 at 14:17
  • @Nupul: I remember when I considered using this some years ago, but it was not supported well enough at that time. (old IE for example) Since then I always used single classes, but of course multiple classes will make things a lot easier. :) – magnattic Aug 08 '11 at 14:25
  • @Joachim Sauer: Oh, didn't know that. Still unfortunately you can't rely on browser to always support all standards. Otherwise web development world would be a much nicer place to live in. ;) – magnattic Aug 08 '11 at 14:30

2 Answers2

6

Nearly any modern browser should support this, it is apparently buggy in IE <= 6, but you should be fine as this lack of functionality would hinder many major sites / applications.

The following link has a chart showing support for multiple CSS classes by browser:

CSS Support By Browser

Netscape 1.0 will probably not support this, as Netscape lacked support for it in 4.0. Source

Netscape 4.0+

  • Multiple class names for an element are not supported.
Rion Williams
  • 74,820
  • 37
  • 200
  • 327
  • I only used Netscape 1.0 as an example for a really outdated browser. ;) Thanks for the answer, glad to hear its well supported. Multiple classes definitly make things easier. – magnattic Aug 08 '11 at 14:26
  • 2
    No problem - didn't know if you had some very strange archaic users in a cave somewhere using Netscape 1.0... :) – Rion Williams Aug 08 '11 at 14:28
1

Yes, every major browser supports this.

Jason Gennaro
  • 34,535
  • 8
  • 65
  • 86