Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / CSS / January 2006



Tip: Looking for answers? Try searching our database.

Can you do Class="multiple classes"?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Giggle Girl - 30 Jan 2006 15:53 GMT
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
Johannes Koch - 30 Jan 2006 16:07 GMT
> I have inherited some CSS from a former employee that has code like
> this:
[quoted text clipped - 5 lines]
>
> 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.

Signature

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

Jukka K. Korpela - 30 Jan 2006 16:43 GMT
> 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.

> 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.

> 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.

> If it is, is there a limit to how many classes you can apply?

Hardly.

> 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.

Signature

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

Giggle Girl - 30 Jan 2006 17:14 GMT
Thank you  Johannes and Yucca for your response.

Very helpfull and informitive.

Ann
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.