开发者

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

How many number of CSS classes can be 开发者_StackOverflowassigned for an HTML element.


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


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


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜