Advanced form labeling (accessible forms)

Keeping in mind accessibility when creating forms is very important. Here are some tips to advanced labeling of the form fields.

Accessible form validation

Multiple fields

With one label

<th id="namelabel" scope="col">Name</th>
<input type="text" name="name1" aria-labelledby="namelabel">
<input type="text" name="name2" aria-labelledby="namelabel">

With multiple labels

<input type="text" name="office1" aria-labelledby="cyndi officenum">

aria-describedby (hint, tooltip)

<label for="resetpass">Reset Password:</label>
<input type="password" id="resetpass" aria-describedby="pwnote"><br>
<span id="pwnote">New password must be 8-15 characters and include letters and numbers.</span>

Fieldset and legend

    <legend>Fruit juice size</legend>
      <input type="radio" name="size" id="size_1" value="small">
      <label for="size_1">Small</label>
      <input type="radio" name="size" id="size_2" value="medium">
      <label for="size_2">Medium</label>
      <input type="radio" name="size" id="size_3" value="large">
      <label for="size_3">Large</label>

When reading the above form, a screen reader will speak “Fruit juice size small” for the first widget, “Fruit juice size medium” for the second, and “Fruit juice size large” for the third.


Handling error messages

Place error message into the label field.

  <label for="fname">First Name:<span class="reqField">*</span><span class="element-invisible" id="fnameErrorHidden">You must enter your first name.</span></label><br>
  <input id="fname" type="text" name="textfield">
  <span class="errorMsg" id="fnameError">&nbsp;You must enter your first name.</span>

Futher reading


Thanks for reading. If you liked it, consider sharing it with friends via:

Let's be in touch!

Don't miss other useful posts. Level up your skills with useful UX, web development, and productivity tips via e-mail.

I want to be up to date via email!

No spam ever (I don't like spam, I don't send spam). You can unsubscribe at any time. Privacy Policy

Don't you want to subscribe via e-mail?

See other ways to keep in touch.


If you want to comment, write a post on social media and @mention me. You can also write to me directly on the contact page.