[whatwg] [WF2] <select required>

Tab Atkins Jr. jackalmage at gmail.com
Thu Oct 23 12:19:18 PDT 2008


On Thu, Oct 23, 2008 at 12:45 PM, Andy Lyttle <whatwg at phroggy.com> wrote:

> On Oct 23, 2008, at 5:31 AM, Ian Hickson wrote:
>
>  This use case is definitely something we want to consider, but I don't
>> think it's about required="". It's about an option in the <select> being a
>> non-option (as it were). <select> by definition can't have nothing
>> selected. That's what it means.
>>
>> The issue about a placeholder value is listed as an open issue in the
>> spec, and will probably be addressed at some future point.
>>
>
> This is an interesting point I hadn't considered.  It's *very* common to
> use the first <option> in a <select> as a non-choice such as "Choose
> one...", setting the value to something unique (often "" but it could be
> something else if "" is a valid choice) so it can be treated as a
> non-selection.  This serves *precisely* the same purpose as the placeholder
> attribute on text input fields, which I had assumed wouldn't be valid for
> <select>.
>
> I suggest that the placeholder attribute should indeed apply to <select>,
> and the behavior should be similar to the current practice of using the
> first <option>.  In particular, the placeholder should appear both on the
> collapsed menu, and at the top of the open menu, although it should not be
> selectable.
>
> But the question is, when the menu is collapsed, when should the
> placeholder be displayed instead of one of the options?  Any time the value
> is ""?  Only until the user selects something?  Somebody smarter than me,
> please figure this out. :-)


Very nice; I like the idea of expanding the proposed placeholder/hint
attribute, and this does indeed seem perfect for it.

Ultimately the display of the hint is, and should be, up to the UA, so that
non-full-featured devices can display things in a maximally helpful way to
the user.  Within the context of a standard browser on an ordinary computer,
though, the correct display seems relatively clear.  When the select is
collapsed, the hint should show until the user selects something.  After the
user selects something, the hint will never again display in the collapsed
state.  I'm not sure if it's necessary for the hint to display in the
expanded state.  If it is, though, then it should always be the first item
in the list, and it should be nonselectable, similar to how column groups
display currently.

~TJ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20081023/aa81163c/attachment-0001.htm>


More information about the whatwg mailing list