act-rules / act-rules.github.io

Accessibility conformance testing rules for HTML
https://act-rules.github.io/
Other
136 stars 67 forks source link

Placeholder should not be allowed as a label for Pass 5 [e086e5] #2070

Closed tombrunet closed 1 year ago

tombrunet commented 1 year ago

We use an input with a placeholder attribute as a pass example for accessible name (see https://act-rules.github.io/rules/e086e5#passed-example-5)

However, ARIA spec and Accessible Name and Description Computation 1.2 don't mention the placeholder as an accessible name. And, HTML explicitly says that this should not be done:

The placeholder attribute should not be used as an alternative to a label. For a longer hint or other advisory text, the title attribute is more appropriate.

The only support we can find is that the browsers happen to do it (though MDN docs also say not to do it - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input )

The placeholder should never be required to understand your forms. It is not a label, and should not be used as a substitute, because it isn't. The placeholder is used to provide a hint as to what an inputted value should look like, not an explanation or prompt.

I'm suggesting we simply remove this as a pass example.

Jym77 commented 1 year ago

Placeholder is explicitly mentioned in the [HTML AAM)(https://www.w3.org/TR/html-aam-1.0/#input-type-text-input-type-password-input-type-number-input-type-search-input-type-tel-input-type-email-input-type-url-and-textarea-element-accessible-name-computation) (step 4). It is indeed not recommended, but still working (and browsers are indeed doing it, so an input field with a placeholder does have an accessible name and passes 4.1.2).

tombrunet commented 1 year ago

@Jym77 Thank you. I figured we hadn't just made that up, but we couldn't find any mention in the HTML, ARIA, or ARIA in HTML specs beyond the indication of the opposite.