[whatwg] datalist element example and option element content model

Michael[tm] Smith mike at w3.org
Wed Aug 7 11:34:26 PDT 2013

Kurosawa Takeshi <taken.spc at gmail.com>, 2013-07-18 09:24 +0900:

> I noticed inconsistency between datalist element example and option
> element content model.
> In a datalist element's code example, there are option elements which
> don't specify label attribute and are empty.
> 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>>

Those option elements aren't empty. They contain text nodes. Those text
nodes are just whitespace but for them to be completely empty, the markup
would instead need to be something like:

  <datalist id=sexes>
   <option value="Female"><option value="Male"></datalist>

..Which would then actually be invalid per the spec.

> However option element section prohibits such condition.

The current spec doesn't prohibit the example you gave above. The spec
just says, "the element itself must not be empty". But those option
elements aren't empty, so as far as the spec goes, they're conforming.

> > 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#the-option-element
> My question is which one is correct: the code example or the option
> element section.

They're both correct.

It may be that what we want the spec to say here instead is that the text
content of label-less option element must contain characters other than
whitespace. But that's not what the spec says now.

If you think the spec should say that, you should probably file a spec bug.


Michael[tm] Smith http://people.w3.org/mike

More information about the whatwg mailing list