Andrew Fedoniouk points out that it's not entirely clear whether/how :blank applies to radio buttons etc.
https://lists.w3.org/Archives/Public/www-style/2018Nov/0028.html
We should clarify this. Some options are:
Probably the most simple definition is 1; it largely falls out of the existing definition. However the last definition is perhaps more useful. It would be good to hear from authors here what they expect.
The very first thing that came to mind for me was that input[type=checkbox]:blank
would essentially be the same as writing input[type=checkbox]:not(:checked)
.
This is because if a checkbox is not checked, it visually tends to appear blank.
If input[type=checkbox]:not(:checked)
does the same thing as input[type=checkbox]:blank
then I don't see the point in having input[type=checkbox]:blank
aside from a slightly cleaner syntax.
I like the last definition, i.e. let :blank
select form controls which, supposing they had the required
attribute and were mutable, would suffer from being missing. This would mean:
:blank
behaves like :not(:checked)
.:blank
matches if no element in the radio button group is checked.:blank
matches if the list of selected files is empty.:blank
matches if no option is selected, or if the only selected option is the placeholder label option.:blank
never matches.:blank
matches if the value is not empty.@Loirooriol Overall I agree with you, except for checkboxes: checkboxes can also be grouped and it makes sense to treat them like radio buttons. Checkbox groups are essentially like radio button groups, except that the items are non-exclusive. You'll see surveys, for example, vary between checkboxes and radio buttons for the same format of question, except that they use checkboxes when they want to allow multiple selections.
@fantasai "checkboxes can also be grouped". Any reference to this? In the spec I can find the radio button group concept and the RadioNodeList interface. I can't find anything analogous for checkboxes.
Multiple checkboxes can have the same name, not sure if this is what you mean. But this also applies to text inputs, and doesn't mean they are grouped in some special way.
And I think it's natural to say that a form control suffers from being missing if it's blank and it's required (and possibly other constraints like mutability). So I would define :blank this way, and checkbox groups are not considered when determining if it suffers from being missing.
Most helpful comment
I like the last definition, i.e. let
:blank
select form controls which, supposing they had therequired
attribute and were mutable, would suffer from being missing. This would mean::blank
behaves like:not(:checked)
.:blank
matches if no element in the radio button group is checked.:blank
matches if the list of selected files is empty.:blank
matches if no option is selected, or if the only selected option is the placeholder label option.:blank
never matches.:blank
matches if the value is not empty.