Dave Taylor
Dave Taylor

Reputation: 2045

Please clarify the W3C Label tag use

The W3C Specification for the label tag http://www.w3.org/TR/html401/interact/forms.html#h-17.9.1 says:

The LABEL element may be used to attach information to controls

Does "information" include error messages?

Upvotes: 4

Views: 343

Answers (1)

vbence
vbence

Reputation: 20343

You can use it, as it is possible to attach more labels to a single input.

It also have accessibility considerations. This article recommends the following (mind the role attribute):

<label for="userEmail" role="alert">That email address is invalid.</label>

Upvotes: 5

Related Questions