why is :hover harmful?

In :hover Considered Harmful Jeremy Keith states that the pseudo class :hover in CSS crosses over into DOM territory.

I disagree.

The :hover does nothing except tell how an element should look in a certain case, not how this element is triggered or that case is reached. Isn't that what CSS was about? The switching to this case is handled by the browser... and you could go so far as to say that the browser engine crosses over into DOM territory by triggering the hoverstate on mouseover, but why would you have to script everything on your site?

Similarly I'm kinda annoyed why I cannot create my own pseudo classes and write scripts for it.
edited:2004-08-11 15:28:54

You say:

"The :hover does nothing except tell how an element should look in a certain case, not how this element is triggered or that case is reached."

Yes it does. It says "display it like this *when the cursor hovers over it*". The second part of that statement is very much part of the behaviour layer.

"Isn't that what CSS was about?"

No. CSS is about defining how things should look, not how they behave. It's fair enough to have a class in CSS that defines how something should look when it's hovered over (e.g. class="over" and class="off"). That would be saying how an element should look in a certain case. But then triggering the switch should be handled by JavaScript.

afbeelding van jadwigo

Thanks for your reply.

For another example, in ALA suckerfish dropdowns and other similar effects the javascript creates a class ".over" when the mouse hovers.. that class is then applied to the element.

The effect is the same, the means similar - you use CSS to define the layout of a different state of an element - and CSS itself does nothing to get to that state, in the :hover case the browser triggers it, in the .over state javascript triggers it.

The behavior layer in my opinion is not exclusive to javascript, especially on my mobile phone or on a browser in a security paranoid environment. So that's why I believe not only JavaScript should be able to trigger behavior.