Ugesh Gali
Ugesh Gali

Reputation: 2152

Maximum limit of CSS classes that can be assigned to HTML element?

How many number of CSS classes can be assigned for an HTML element.

Upvotes: 10

Views: 4475

Answers (5)

user1748622
user1748622

Reputation: 21

I'm pretty sure IE6 only supports up to 2. Modern browers have no limit as far as i know.

Upvotes: 2

Pranay Rana
Pranay Rana

Reputation: 176896

One of the lesser known tricks with CSS is the fact that you don't have to limit your elements to just one class. If you need to set multiple classes on an element, you add them simply by separating them with a space in your attribute. For example:

<p class="pullquote btmmargin left">...</p>

So there is no limit on no of classes you apply.

Upvotes: 1

Alan Haggai Alavi
Alan Haggai Alavi

Reputation: 74202

There are no such limitations imposed by the specification:

class

The attribute, if specified, must have a value that is a set of space-separated tokens representing the various classes that the element belongs to.

A set of space-separated tokens is a string containing zero or more words separated by one or more space characters, where words consist of any string of one or more characters, none of which are space characters.of which are space characters.

Upvotes: 4

Matthew Flaschen
Matthew Flaschen

Reputation: 284786

The standard does not specify any limitation, but individual browsers may have practical ones.

Upvotes: 7

janosrusiczki
janosrusiczki

Reputation: 1931

I don't think there's a limit. A quick Google search yielded this.

Upvotes: 10

Related Questions