...

View Full Version : is it possible (and 'legal') to define two classes



ShMiL
12-09-2005, 01:24 PM
to the same objhect?

NancyJ
12-09-2005, 01:27 PM
you can have both ID and class but not multiple of either AFAIK

Bill Posters
12-09-2005, 01:30 PM
You can use multiple, space delimited classes, though support is likely to be limited to more recent browser version.

e.g.

class="class1 class2 class3"

[edit]

Support info…

http://www.pixelsurge.com/experiment/multiplestyles.htm
http://www.quirksmode.org/index.html?/css/multipleclasses.html

ShMiL
12-09-2005, 02:22 PM
You can use multiple, space delimited classes, though support is likely to be limited to more recent browser version.

e.g.

class="class1 class2 class3"

[edit]

Support info…

http://www.pixelsurge.com/experiment/multiplestyles.htm
http://www.quirksmode.org/index.html?/css/multipleclasses.html

it works, but is it valid?

Bill Posters
12-09-2005, 02:31 PM
it works, but is it valid?

I wouldn't suggest it if it wasn't. ;)


7.5.2 Element identifiers: the id and class attributes

Attribute definitions



This attribute assigns a class name or set of class names to an element. Any number of elements may be assigned the same class name or names. Multiple class names must be separated by white space characters.
http://www.w3.org/TR/REC-html40/struct/global.html#h-7.5.2

If in doubt, you could try running a page which uses multiple class values through the validator.

ShMiL
12-09-2005, 02:47 PM
this confused me a bit, but after I read it again, i got it...

Note: Only one class attribute can be specified per HTML element! The example

http://www.w3schools.com/css/css_syntax.asp

thanks :)

felgall
12-09-2005, 08:39 PM
You are only allowed one class attribute but that attribute can contain multiple space separated class names.

ShMiL
12-09-2005, 09:31 PM
You are only allowed one class attribute but that attribute can contain multiple space separated class names.

yeah, I got it :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum