Re: Datalist - option error
"Jukka K. Korpela" <[email protected]> Thu, 30 Jul 2015 16:07:23 +0300
| Newsgroups | gmane.org.w3c.validator |
|---|---|
| Message-ID | <[email protected]> |
7/27/2015, 4:21 PM, [email protected] wrote: > *Error*:Element|option|without attribute|label|must not be empty. This error message directly reflects a requirement on the <option>=20 element in the W3C HTML5 REC. According to it, the content model (i.e.=20 rules for allowed and required content) says: Content model: If the element has a label attribute and a value attribute: Empty. If the element has a label attribute but no value attribute: Text. If the element has no label attribute: Text that is not inter-element=20 whitespace. http://www.w3.org/TR/html5/forms.html#the-option-element So when you have > <option value=3D"RdC"> the third alternative above applies, and it says that the element must=20 gave some non-blank content. But your document contains a sequence of=20 <option> tags, with just line breaks and maybe spaces between, making=20 the content consist of =E2=80=9Cinter-element whitespace=E2=80=9D only. However, the W3C HTML5 REC itself contains the following example of a=20 <datalist> element: <label> Sex: <input name=3Dsex list=3Dsexes> <datalist id=3Dsexes> <option value=3D"Female"> <option value=3D"Male"> </datalist> </label> which causes the same error message. So there is an inconsistency in the=20 specification, and the validator happens to apply the rules under=20 =E2=80=9CContent model=E2=80=9D. The obvious way to make the code validate, considering the context of a=20 <datalist> element, is to duplicate the information, e.g. <option value=3D"RdC" label=3D"RdC"> Maybe the authors of the specification really meant this, and maybe the=20 example not using the label attribute is a holdover from earlier drafts. Yucca