error message W3C on select

W3C validator feedback for aria-required on a select element

Update: this issues has been fixed!

While testing code for a form I came upon an error message in the W3C validator on validator.w3.org, that I could not understand. I created a codepen to do some more testing. And found that adding aria-required to a select element triggers an unrelated error.

Data collected from

Base form code

This is simplified code, just to test the select error messages.

<form>
    <label for="select">Select</label>
    <select id="select">
        <option value="">Choose</option>
        <option value="One">One</option>
        <option value="Two">Two</option>
        <option value="Three">Three</option>
    </select>
    <button>Submit</button>
</form>

The generated error messages

Attributes and error messaes
Attributes for selectError message
requiredNo error
aria-required=”true”Element select is missing one or more of the following attributes: aria-expanded, role.
required aria-required=”true”Element select is missing one or more of the following attributes: aria-expanded, role.
required aria-required=”true” aria-invalid=”false”Element select is missing one or more of the following attributes: aria-expanded, role.
required aria-required=”true” aria-invalid=”true”Element select is missing one or more of the following attributes: aria-expanded, role.
required aria-invalid=”false”No error
required aria-invalid=”true”No error
aria-invalid=”false”No error
aria-invalid=”true”No error
aria-required=”false”Element select is missing one or more of the following attributes: aria-expanded, role.

Conclusion

Adding aria-required as attribute to the select element gives the error warning with the W3C validator tool: “Element select is missing one or more of the following attributes: aria-expanded, role”. Which is not helpful to the tester and can cause developers to unnecessarily add a role and extra aria to an element that does not need that.

Is aria-required for a select a special case? Because I could not find any specific data on this.

I created a GitHub issue for this on he validator repo: Use of aria-required on a select element trigges an error with unrelated feedback

2 thoughts on “W3C validator feedback for aria-required on a select element”

  1. I’m afraid I don’t have an answer but if you follow the “report and issue” link at the bottom of the page you’ll be able to discuss on the github repository.

Comments are closed.