Open Bug 294229 Opened 20 years ago Updated 2 years ago

No handling on <option> tags for CSS ":hover" selector

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

defect

Tracking

()

People

(Reporter: bugs, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511

CSS event-based selector ":hover" should be handled for <option> elements.
Sometimes the default gray background looks inappropriate to the design of the
page; on some layouts it may even be confusing.
I don't see why not to enable handling of type "option:hover { }" and
"option.classname:hover { }" in CSS.

Reproducible: Always

Steps to Reproduce:
1. Define non-standard style for ".bla:hover" in the CSS stylesheet
2. Create a <select> tag with few options
3. Assign class "bla" to one or more of the options
4. Open the page in Mozilla and hover the altered options
Actual Results:  
The colors of the menu item change to default ones: gray and black in my case

Expected Results:  
The colors should change according to the style information defined

CSS2 specs do not say anything about excluding elements from the ":hover"
pseudoclass: http://www.w3.org/TR/REC-CSS2/selector.html#dynamic-pseudo-classes
Given that CSS in general doesn't really specify how it applies to any elements
that are not part of the CSS box model (eg form controls), this behavior is
completely per spec.  Not sure whether it's the behavior we want, though.
I can't think of any particular reason why we should disallow :hover on <option>s.
It's a matter of where events are delivered.  At the moment, <select> is treated
as a black box from the ESM's point of view last I checked.  We could perhaps
change that (and allow focus and hover to be on a particular option, etc), but
it would be a pretty big change.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows XP → All
Hardware: PC → All
The strange fact is background-image works with option:hover, as signalled by Whatrevolution at Userstyle forum: 
http://userstyles.org/forum/comments.php?DiscussionID=1088&page=1#Item_3

See this test page:
http://lucasmalor.netsons.org/option-hover_test.html
Sounds like this bug is no longer a problem, then...
I don't think so... if you want to reproduce background-color or option:hover, you must create a 1px image and set it as background-image, repeating it along x and y axes. A mess.

IMO it's a behaviour many people will be happy to see in Firefox:
http://www.google.com/search?name=f&hl=en&q=option%3Ahover
The background/color painted for selected options in a select are just the system "selected option" colors, iirc.

It's possible to make page styles override that, perhaps.  But that's not the same as this bug as originally filed; back then I think :hover really just didn't apply to <option>s.
(In reply to comment #7)
> The background/color painted for selected options in a select are just the
> system "selected option" colors, iirc.

Yes, but this is a Firefox choice to be consistent with OS settings. Firefox set also a default value for document colour and background colour, but you an change them with CSS.

> I think :hover really just didn't apply to <option>s

Well, but currently it works with background-image... so IMO it's not undesirable. I don't know if this is hard to code, but it will not break any W3C spec and some people will be happy to see it. Nothing crucial, but something useful.
Assignee: events → nobody
QA Contact: ian → events
Component: Event Handling → User events and focus handling
Severity: minor → S4
You need to log in before you can comment on or make changes to this bug.