- From: Ian Hickson <ian@hixie.ch>
- Date: Mon, 21 Apr 2003 04:39:27 -0700 (PDT)
- To: Tom Gilder <tom@tom.me.uk>
- Cc: "www-style@w3.org" <www-style@w3.org>
On Mon, 21 Apr 2003, Tom Gilder wrote: > > Is there a reason why there couldn't be a way to select elmemets by > IDs, based on an attribute of another element? > > For instance, something like (this syntax isn't too good though): > > <label for="me">text</label> <input .. id="me"> > > label:focus #attr(for) { color: red; } > > ...would make the input red when label is focussed. Would be quite > handy imo. At some point in the distant past I proposed the /foo/ combinator. This would style the above as: label:focus /for/ * { color: red; } ...that is, "any element pointed to using the 'for' attribute on an element whose tag name is 'label' and which is currently focussed". See part 2 of: http://lists.w3.org/Archives/Public/www-style/2000Jan/0152.html Note that it is unlikely that a "label" element would ever be focussed; the input element would be instead. The reverse styling (styling the label based on the focussed input) would be more commonly wanted, I imagine. This would require the :matches() pseudo-class as well, as in: label:matches(# /for/ :focus) { font-weight: bold; } ...which reads "any 'label' element whose 'for' attribute points to an element that is currently focussed". -- Ian Hickson )\._.,--....,'``. fL "meow" /, _.. \ _\ ;`._ ,. http://index.hixie.ch/ `._.-(,_..'--(,_..'`-.;.'
Received on Monday, 21 April 2003 07:38:35 UTC