[whatwg] Should :default apply to checkboxes, radios, and options?
Ian Hickson
ian at hixie.ch
Mon Aug 2 17:46:15 PDT 2010
On Fri, 30 Apr 2010, L. David Baron wrote:
>
> For a long time, Gecko has implemented the behavior that the
> :default pseudo-class matches checkboxes, radios, and options that
> are selected by default (i.e., anything that matches :checked by
> default). I think supporting it for option elements is explicitly
> stated in the spec where :default was introduced:
> # One example is the default submit button among a set of buttons.
> # Another example is the default option from a popup menu.
> # Multiple elements in a select-many group could have multiple
> # :default elements, like a selection of pizza toppings for
> # example.
> -- http://www.w3.org/TR/css3-ui/#pseudo-default
> and I think supporting it for radios and checkboxes logically
> follows from that.
>
> However, the HTML5 spec says that :default should not apply in these
> cases:
> http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#selector-default
>
> I don't feel particularly strongly about this one, but it seems like the
> original intent of :default was to match both things that are the
> "default button" and things that are "selected by default".
>
> Was this difference with existing implementation behavior intentional?
No, that particular definition just didn't come to mind.
On Fri, 30 Apr 2010, Jonas Sicking wrote:
>
> Out of curiosity, what is the use case for :default?
On Fri, 30 Apr 2010, L. David Baron wrote:
>
> For buttons, it's common to present the button that's the default action
> for a dialog (the one that submits if you hit enter in a textfield, for
> example), with a thicker border. (For example, in dialog boxes in
> Windows.)
>
> For radios/checkboxes, one might want to present the labels
> corresponding to the current state in a different font (perhaps bold?)
> or color so that if a user switches away from the defaults they can
> switch back without having to remember what they changed. (I believe
> I've seen UI that does this, although I can't think where.)
Since nobody seemed to object to this, and we already have an
implementation, I've added it to the spec. I don't feel strongly about
this either.
Note that the definition of :default isn't quite the same as what is
:checked by default. For example, the first <option> here matches
:default, even though the second is the one that matches :checked by
default, and indeed the first can never match :checked while disabled:
<select>
<option disabled selected>A
<option>B
</select>
I did this for compat with Firefox. We could change it but it would make
the rules somewhat more convoluted.
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg
mailing list