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