- From: Jukka K. Korpela <jkorpela@cs.tut.fi>
- Date: Wed, 16 Apr 2014 22:41:17 +0300
- To: Ken Geis <kgeis@berkeley.edu>, "www-validator@w3.org" <www-validator@w3.org>
2014-04-16 21:00, Ken Geis wrote: > I guess I have a problem with the spec. HTML5 CR is still a draft, though probably close to being final. Issues with it are best discussed in the www-html list. > I believe that if my select is > required and I have an option selected, then I should not need a > placeholder. The drafts thinks otherwise, and I think it's more logical. If an option is initially selected, due to the attribute, then the select control always has a value. Unless that value is set to the empty string (<option selected value="">), which would be rather anomalous, there is no point in using the attribute required. It would express a requirement that is always fulfilled. > From what I've read, the following situation would be > legitimate in HTML 4.01 but not in HTML 5. > > <!DOCTYPE html> > <title>test</title> > <select size=1 required> > <optgroup label=jkldf> > <option selected>hello > </optgroup> > </select> The attribute required is not in HTML 4.01 at all. In HTML5, you can use that attribute to make user input required (in a sense described in the draft: trying to submit the form fails if no input has been given etc.). For a <select> element, this means that the user must make a choice. This is incompatible with the idea of setting a default value. So this is not just about validation, but also functionality. What if the attribute selected is not there? Well, the traditional behavior of browsers is that they act as if the first option were pre-selected. So to make input (selection of some option) required, you need to play the game where you have a dummy first option with value="". It gets pre-selected (even if the attribute selected is not used), but with an empty value, it does not satisfy the requiredness constraint. That is, the user is "forced" to select some real option. Yucca
Received on Wednesday, 16 April 2014 19:41:48 UTC