HighDots Forums  

Can you do Class="multiple classes"?

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Can you do Class="multiple classes"? in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Giggle Girl
 
Posts: n/a

Default Can you do Class="multiple classes"? - 01-30-2006 , 09:53 AM






I have inherited some CSS from a former employee that has code like
this:

onmouseover="this.className='highlight_on standard_border'"

where it appears to activate two different classes, "highlight_on" and
"standard_border".

Is this valid CSS?

If it is, is there a limit to how many classes you can apply? Any
other comments on this, or things I should know relating to it?

Thank you,
Ann


Reply With Quote
  #2  
Old   
Johannes Koch
 
Posts: n/a

Default Re: Can you do Class="multiple classes"? - 01-30-2006 , 10:07 AM






Giggle Girl wrote:

Quote:
I have inherited some CSS from a former employee that has code like
this:

onmouseover="this.className='highlight_on standard_border'"

where it appears to activate two different classes, "highlight_on" and
"standard_border".

Is this valid CSS?
See <http://www.w3.org/TR/html4/struct/global.html#adef-class>:

class = cdata-list [CS]
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.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)


Reply With Quote
  #3  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Can you do Class="multiple classes"? - 01-30-2006 , 10:43 AM



"Giggle Girl" <missgiggy (AT) gmail (DOT) com> wrote:

Quote:
I have inherited some CSS from a former employee that has code like
this:

onmouseover="this.className='highlight_on standard_border'"
The code is just as foolish as it looks like. This illustrates well why class
names should describe the meaning (semantics) of elements rather than their
casual appearance.

The reason for using JavaScript here is probably the fact that IE does not
support the :hover pseudoelement except for links. But that's not a reason
for using foolish class names. Besides, _is_ this a non-link element? As
usual, the URL etc. etc.

Quote:
where it appears to activate two different classes, "highlight_on" and
"standard_border".
It activates nothing. It assigns two classes to the element.

Most probably, things could have been written better by using a single class,
say "hovered", and setting what you like to set for it. However, it's usually
non-productive to try to fix sloppy code.

Quote:
Is this valid CSS?
Technically, it's not CSS. There is no CSS construct in the code snippet. But
class="highlight_on standard_border" would be valid (though foolish) HTML,
and JavaScript lets you assign two classes that way, too.

Quote:
If it is, is there a limit to how many classes you can apply?
Hardly.

Quote:
Any other comments on this, or things I should know relating to it?
Let it be unless it causes real trouble. Don't imitate it.

--
Yucca, http://www.cs.tut.fi/~jkorpela/


Reply With Quote
  #4  
Old   
Giggle Girl
 
Posts: n/a

Default Re: Can you do Class="multiple classes"? - 01-30-2006 , 11:14 AM



Thank you Johannes and Yucca for your response.

Very helpfull and informitive.

Ann


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.