W3C home > Mailing lists > Public > www-validator@w3.org > April 2014

Re: [VE] [html5] spurious "must have child option" when all options in optgroups

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Wed, 16 Apr 2014 20:25:08 +0300
Message-ID: <534EBCF4.4090604@cs.tut.fi>
To: "www-validator@w3.org" <www-validator@w3.org>
CC: Ken Geis <kgeis@berkeley.edu>
2014-04-16 17:25, Philip Taylor wrote:

> (a) We should point out to Mr Geis that reading the HTML 4.01
> specification is not always useful when deciding what is or
> is not valid in HTML 5,

Or, more exactly, that HTML 4.01 as such is irrelevant in that respect. 
There is no exact definition of exactly what HTML5 validation checks 
against, but it’s presumably either HTML5 CR or HTML 5.1 Nightly or 
something between them, as interpreted and modified by the authors of 
the validator.

> (b) Mr Geis specifically quoted "A select element with a /required/
> attribute a ...", and this example, which meets that constraint, does
> indeed fail as he asserts :
>
> <!DOCTYPE html>
> <title>test</title>
> <select size=1 required>
> <optgroup label=jkldf>
>     <option>hello
> </optgroup>
> </select>

That is correct, in two ways. It indeed fails, and failing validation is 
consistent with HTML5 CR, which says:

"If a select element has a required attribute specified, does not have a 
multiple attribute specified, and has a display size of 1; and if the 
value of the first option element in the select element's list of 
options (if any) is the empty string, and that option element's parent 
node is the select element (and not an optgroup element), then that 
option is the select element's placeholder label option.

If a select element has a required attribute specified, does not have a 
multiple attribute specified, and has a display size of 1, then the 
select element must have a placeholder label option."
   http://www.w3.org/TR/html5/forms.html#the-select-element

It sounds complicated, and it is almost as complicated as it sounds. But 
reading backwards, the rules here say that in the given case, the 
<select> element must have a "placeholder label option", which means an 
<option> element that either has value="" or has no value attribute and 
no text content - a dummy option indeed. Moreover, the <option> element 
must be the first child of the <select> element, for example

<select size=1 required>
<option value="">Please select the greeting:
<optgroup label=jkldf>
    <option>hello
</optgroup>
</select>

This requirement has a fairly complex history. But the point is that it 
is in the HTML5 CR, so the error message "A select element with a 
required attribute and without a multiple attribute, and whose size is 
1, must have a child option element" is adequate (though not ideal 
perhaps in its formulation).

Yucca
Received on Wednesday, 16 April 2014 17:25:39 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 14:18:10 UTC