Comments (4)
Am I missing something here, or did I unveil a validator bug?
The validator conforms to the requirements in the spec here, but the wording could be more clear. So I changed it such that the error message emitted for this case is now this:
The first child option element of a
select
element with arequired
attribute, and without amultiple
attribute, and without asize
attribute whose value is greater than1
, must have either an emptyvalue
attribute, or must have no text content.
Previously it wasn't clear but by “size” the message was meant to be referring to what the HTML spec more precisely calls “display size”—an abstract term of art coined in the spec to define the requirement. But in this there’s no reason it needs to state the requirement through that indirection, because it can instead be stated concretely in terms of the size
attribute. So that's what I made it say now.
So I'm going to go ahead and close this out but if you believe some further fix to the validator is needed here—e.g., if you want to propose some different wording or think the validator is not actually matching the requirements in the spec here—please feel free to reopen it.
On a related note as far as the spec goes, IMHO the actual language in the spec for this requirement could be stated more precisely and clearly, so I filed a spec bug suggesting it be refined: https://www.w3.org/Bugs/Public/show_bug.cgi?id=28150
The spec currently says this:
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.
And I suggested that it be changed to this:
If a select element has a required attribute specified, does not have a multiple attribute specified, and does not have a "sizes" attribute with a value greater than 1, then the select element must have a placeholder label option.
Finally, if you want an explanation of the rationale behind that particular spec requirement, Jukka’s explanation from the following e-mail message is pretty good—
https://lists.w3.org/Archives/Public/www-validator/2014Apr/0020.html
from validator.
Hey @sideshowbarker, thanks for your answer. Detailed I must say, but I am still very confused, if not more.
To my understanding of the (suggested) spec wording and the new error message: the select element has the required attribute specified and does not have a multiple attribute specified. So I guess I meet this error because I have a "display size of 1", and I have no idea what that means...
I tried to remove the selected attribute as per Jukka's explanation but it didn't change anything. And again, my select has 3 elements, that's what I understand with "size".
from validator.
To my understanding of the (suggested) spec wording and the new error message: the select element has the required attribute specified and does not have a multiple attribute specified. So I guess I meet this error because I have a "display size of 1", and I have no idea what that means...
@astorije Is there something unclear about the current error message shown at http://goo.gl/mjto0R ?
That error message doesn't now say anything about "display size of 1"; instead it explicitly says, without a size attribute whose value is greater than 1
. Is there some way I could make that more clear?
So as far as what you'd need to do to to make your markup valid, you have two choices:
A. Use a “placeholder option label”: <option value="">Select a validation option</option>
<select class="form-control" id="validation" required>
<option value="">Select a validation option</option>
<option value="no-validation">No validation</option>
<option value="simple-validation" selected>Simple Validation</option>
<option value="recursive">Recursively validate multipart documents</option>
</select>
B. Use a size
attribute with the appropriate value:
<select class="form-control" id="validation" required size=3>
<select class="form-control" id="validation" required size=3>
<option value="no-validation">No validation</option>
<option value="simple-validation" selected>Simple Validation</option>
<option value="recursive">Recursively validate multipart documents</option>
</select>
The choice just depends on what you prefer to show to the user in the UI: either a normal select drop-down menu, or a 3-row multi-select list box.
I think most people go with the normal select drop-down menu, which is why the spec tries to help here by requiring a “placeholder option label” for this case.
Do you have some suggestion about how I could change the wording of the error message to help users understand that the two solutions are A and B above? Or maybe @Hixie has a suggestion.
from validator.
OK I added some clarifying text to the error message such that it now also says, “Consider either adding a placeholder option label, or adding a size attribute with a value equal to the number of option elements.” Further feedback/suggestions on improving the message here at still much welcome.
from validator.
Related Issues (20)
- CSS being identified as html thus giving error
- Add "onpageswap" attribute to "body" element
- WordPress Gutenberg Block Library CSS incorrect validation HOT 3
- No warning for validator HOT 2
- Icon for "verified html" HOT 2
- Add writingsuggestions attribute
- No error when using ASCII upper alphas in Attribute Name for Custom Data Attributes HOT 1
- Possible misuse of aria-label. (If you disagree with this warning
- Add shadowrootserializable attribute to template element
- the XML syntax is not recommended
- bad my compute
- CSS text-wrap and shape-margin throwing validator errors
- Button with type="button" doesn't support role="combobox"
- Element dialog is missing required attribute role HOT 1
- Error Code 429 - too many requests
- Warnings about non supported, non global ARIA attributes use on ARIA roles
- Misunderstood language HOT 2
- <a> must not appear as a descendant of <button>
- Bad value onion-location for attribute http-equiv on element meta. HOT 1
- False positive on valid CSP `sandbox` values
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from validator.