This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 22994 - Clarify option element's label must be a non empty string.
Summary: Clarify option element's label must be a non empty string.
Status: RESOLVED NEEDSINFO
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-17 05:27 UTC by Takeshi Kurosawa
Modified: 2013-09-12 21:29 UTC (History)
2 users (show)

See Also:


Attachments

Description Takeshi Kurosawa 2013-08-17 05:27:37 UTC
I propose clarifying option element's label must be a non empty string.

# Background
Please see
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2013-August/040406.html

In one of datalist element example, option elements have value content attribute and don't have label content attribute.
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-datalist-element

<label>
 Sex:
 <input name=sex list=sexes>
 <datalist id=sexes>
  <option value="Female">
  <option value="Male">
 </datalist>
</label>

In this case, labels are calculated from option elements' content (text nodes) and are whitespace only string. As current spec doesn't say "label must contain characters other than whitespace", this example is valid (conforming).

However following is invalid as per current spec.
Because option elements don't have any child nodes.

<label>
 Sex:
 <input name=sex list=sexes
 ><datalist id=sexes
  ><option value="Female"
  ><option value="Male"
 ></datalist
></label>

That is non-intuitive.

## Proposal

1. Clarify label of option element must be a string that isn't the empty string

Change the sentence

> The label content attribute, if specified, must not be empty. If the attribute is not specified, then the element itself must not be empty.
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#concept-option-label

to something like

> The label content attribute, if specified, must not be empty. If the attribute is not specified, then the element's text IDL attribute must not be empty


2. Clarify option element which is descendant of datalist element, that has both non empty label and value represents a suggestion.

Change the sentence

> Each option element that is a descendant of the datalist element, that is not disabled, and whose value is a string that isn't the empty string, represents a suggestion.
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-datalist-element

to something like

> Each option element that is a descendant of the datalist element, that is not disabled, and whose value and label are string that isn't the empty string, represents a suggestion.


3. Modify datalist example to match 1. and 2.

Change

<label>
 Sex:
 <input name=sex list=sexes>
 <datalist id=sexes>
  <option value="Female">
  <option value="Male">
 </datalist>
</label>
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-datalist-element

to

<label>
 Sex:
 <input name=sex list=sexes>
 <datalist id=sexes>
  <option>Female
  <option>Male
 </datalist>
</label>
Comment 1 Ian 'Hixie' Hickson 2013-08-20 17:58:09 UTC
I changed this recently for unrelated reasons:

   http://html5.org/tools/web-apps-tracker?from=8146&to=8147

Does that address your concerns satisfactorily?
Comment 2 Takeshi Kurosawa 2013-08-20 23:46:43 UTC
(In reply to comment #1)
> I changed this recently for unrelated reasons:
> 
>    http://html5.org/tools/web-apps-tracker?from=8146&to=8147
> 
> Does that address your concerns satisfactorily?

Thanks. It does.

I noticed proposed example ma cause backward compatibility issue (Female and Male will be rendered on old browsers). So I would like to change proposed example to use label and value attributes.

> <label>
>  Sex:.
>  <input name=sex list=sexes>
>  <datalist id=sexes>
>   <option>Female
>   <option>Male
>  </datalist>
> </label>
Comment 3 Ian 'Hixie' Hickson 2013-08-22 20:28:07 UTC
Which spec are you looking at? I don't see that markup in the HTML standard. Can you provide a URL to the problem?