简体   繁体   中英

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?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM