Open gregwhitworth opened 8 years ago
@frivoal To answer your question, it is still in Edge but off by default behind a flag as no other browser currently implements it this way.
@gregwhitworth do all of them work in edge with the flag? :checked etc?
@bkardell No it doesn't propagate those, I've updated the testcase to include those http://jsbin.com/munatiyega/edit?html,css,output
Related discussion on www-style. (This issue keeps coming up.)
This is a 18 years old discussion in the CSS WG (see Reference Combinator in https://lists.w3.org/Archives/Member/w3c-css-wg/2000JulSep/0214.html and we already discussed it back in '97...) : I think we should not solve the individual <label>
case directly but have a generic mechanism for ID/IDREF references. There are many other ID/IDREF cases in dozens of XML dialects that could benefit from such a generic mechanism, including in EPUB.
@therealglazou That would be nice, but <label>
s can also be associated with descendant form elements without ID/IDREFs, so this seems to have a slightly larger scope.
As an author, this is a somewhat silly example of what I would love to use this functionality for:
<label>2 + 2 = ?
<svg><use href="#correct" /><use href="#incorrect" /></svg>
<input name="answer" pattern="4" required />
</label>
use {
display: none;
}
label:valid > [href="#correct"],
label:invalid > [href="#incorrect"] {
display: inline;
}
It’s sort of possible today to do this by placing the elements after the form element in question and using something like input:valid ~ foo
, but that can be impossible with certain markup output — it’s common to wrap <select>
inside a <span>
for styling purposes, for example.
As someone who's never worked on a layout engine, I have trouble understanding how this would add much more complexity. The argument against it I saw is that the engine would have to keep track of the element of the associated input. But UAs already do this to some extent—a <label>
is almost treated as an extension of its referenced input, allowing you to click a label to tick a checkbox or radio button.
To me, this feature just seems implied from the already present behavior, but perhaps I'm misunderstanding something.
The CSS Working Group just discussed <label> elements
, and agreed to the following:
RESOLVED: Push this out to Level 5
I am strongly opposed to let labels directly reflect the pseudo-classes of the associated form control.
label
or not is confusing.Therefore, solving this use case via a pseudo-class function like :for()
as discussed in #1067 is much more logical, in my eyes. Furthermore a function like that has the advantage of being extensible and covering more than just form control states.
Sebastian
This discussion was taking place in the WHATWG, moving this over to the CSSWG repo so all CSS members see it and are able to engage. For reference, here is the issue for more context: https://github.com/whatwg/html/issues/1632#issuecomment-238429326