liveBook · Manning

Required attribute

As explained in Architecting Accessibility

An HTML attribute that indicates that a form control must have a value before its form can be submitted.

The HTML `required` attribute marks a form control as mandatory and exposes that requirement to assistive technologies. Pair it with visible “(required)” text in the field label so people can recognize required fields without relying on symbols or color. section 6.1.2 section 6.1.10

...
<p>
  Required fields are marked with an asterisk (*) #A
</p>    ...
<div> 
  <label for="booking-ref">
    Booking reference * #B
  </label>
  <p id="booking-ref-hint"> #C
    Enter the 8-character code from your confirmation email (BID12345)
  </p>
  <input   
    id="booking-ref" 
    name="booking-ref" 
    type="text" 
    required #D
    aria-describedby="booking-ref-hint"> #E
</div>
...

The booking-reference field pairs a required control with a visible marker and a description of the expected format and where to find it. section 6.1.2

Make the requirement clear to people completing the form:

  • Prefer the word “required” next to each label over an asterisk alone. If nearly every field is mandatory, a form-level note is possible, but users must remember it. section 6.1.2
  • Review optional fields and remove those that are not needed for the task; fewer unnecessary inputs can reduce perceived effort. section 6.1.2

How Architecting Accessibility covers it

How deep it goes
Explains how the attribute exposes a required state to assistive technologies, without detailing its implementation.
Examples
Uses a booking-reference field and a dog-owner form to pair required controls with visible labels and instructions.
What you can do after
Apply the required attribute alongside visible “required” label text to communicate mandatory fields programmatically and visually.
How it connects
Connects required fields with form labels, assistive technologies, input instructions, and form validation.

Also explained in

Compare how 2 books explain required attribute →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Architecting Accessibility. The section links point to the parts of the book it draws on.