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 22802 - Validation of the select element and empty options differ from the HTML5 spec
Summary: Validation of the select element and empty options differ from the HTML5 spec
Status: RESOLVED WONTFIX
Alias: None
Product: HTML Checker
Classification: Unclassified
Component: General (show other bugs)
Version: unspecified
Hardware: PC other
: P2 normal
Target Milestone: ---
Assignee: Michael[tm] Smith
QA Contact: qa-dev tracking
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-25 16:36 UTC by Laurent Goderre
Modified: 2015-03-30 09:12 UTC (History)
4 users (show)

See Also:


Attachments

Description Laurent Goderre 2013-07-25 16:36:17 UTC
When I validate this page:

http://wet-boew.github.io/wet-boew/demos/formvalid/formvalid-eng.html

I Get the following error:

Error: Element option without attribute label must not be empty.

From line 104, column 9; to line 104, column 17

>↩<option></option>↩<opti

Here is what the spec says about empty option elements (http://www.w3.org/TR/html51/forms.html#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; 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.

An empty option element should be permitted as the first child of an select element.
Comment 1 Michael[tm] Smith 2013-08-05 15:05:04 UTC
(In reply to comment #0)
> When I validate this page:
> 
> http://wet-boew.github.io/wet-boew/demos/formvalid/formvalid-eng.html
> 
> I Get the following error:
> 
> Error: Element option without attribute label must not be empty.

Yeah, that error is correct. The spec says that an empty option element without an a label attribute is a document-conformance error.

  http://www.w3.org/TR/html51/forms.html#attr-option-label

"The label content attribute, if specified, must not be empty. If the attribute is not specified, then the element itself must not be empty."

> Here is what the spec says about empty option elements
> (http://www.w3.org/TR/html51/forms.html#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; 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.

That part of the spec isn't giving document-conformance requirements. It's instead specifying required user-agent behavior.

> An empty option element should be permitted as the first child of an select
> element.

That's not what that part of the spec is saying.
Comment 2 Kyle 2015-03-12 19:11:37 UTC
> > I Get the following error:
> > 
> > Error: Element option without attribute label must not be empty.
> 
> Yeah, that error is correct. The spec says that an empty option element
> without an a label attribute is a document-conformance error.
> 
>   http://www.w3.org/TR/html51/forms.html#attr-option-label
> 
> "The label content attribute, if specified, must not be empty. If the
> attribute is not specified, then the element itself must not be empty."

By following the provided link, I'm not able to locate the second sentence "If the attribute is not specified, then the element itself must not be empty."

Is it possible the spec has been amended and the validation service should be updated?  It seems that empty option elements "<option value=''></option>" should be allowed in HTML5, especially for <select> elements that do not have the required attribute specified.

Apologies for bringing this to light again a year and a half later.
Comment 3 Michael[tm] Smith 2015-03-27 13:48:14 UTC
(In reply to Kyle from comment #2)
> > > I Get the following error:
> > > 
> > > Error: Element option without attribute label must not be empty.
> > 
> > Yeah, that error is correct. The spec says that an empty option element
> > without an a label attribute is a document-conformance error.
> > 
> >   http://www.w3.org/TR/html51/forms.html#attr-option-label
> > 
> > "The label content attribute, if specified, must not be empty. If the
> > attribute is not specified, then the element itself must not be empty."
> 
> By following the provided link, I'm not able to locate the second sentence
> "If the attribute is not specified, then the element itself must not be
> empty."
> 
> Is it possible the spec has been amended and the validation service should
> be updated?  It seems that empty option elements "<option
> value=''></option>" should be allowed in HTML5, especially for <select>
> elements that do not have the required attribute specified.
> 
> Apologies for bringing this to light again a year and a half later.

Thanks for catching this. In fact it looks like the spec has since changed. Steve Faulkner also reported this separately. So I think I need to remove this check from the validator sources.
Comment 4 Michael[tm] Smith 2015-03-27 14:01:22 UTC
OK actually looking back at the spec, I see I misspoke.

http://www.w3.org/TR/html/forms.html#the-option-element

See the "Content model" section; this part:

> If the element has no label attribute: Text that is not inter-element whitespace.

That's just restating the same "If the [label] attribute is not specified, then the element itself must not be empty." the spec had before.

So I'm re-resolving this as "worksforme".