GSA-TTS/all_sorns

a11y: Search input is missing an accessible name/label

Closed this issue · 0 comments

Description:

Form controls must have accessible names.

Screenshot:

screenshot of unlabeled search input

WCAG SC:

Recommended fix:

The second-level heading (h2) above the search form would make for a good label for the search input.

Current code:

<h2>Search for SORNs by entering a keyword (will return exact matches)</h2>

Proposed code:

<label for="general-search">Search for SORNs by entering a keyword (will return exact matches)</label>

Alternate fix:

If the team would prefer to keep the h2 as-is, then the search input could be assigned an aria-label attribute with a concise value to serve as the input's label, like:

<input class="usa-input" id="general-search" type="search" name="search" value="<%= params[:search] %>" aria-label="search"></input> 

Non-essential related code found:

There is a fieldset element wrapping the search input and button which is unnecessary. Fieldsets are typically used to represent "a set of form controls optionally grouped under a common name" (W3C HTML 5 Spec). If this is being used to attach CSS classes for presentational purposes, the div element may be a better choice here.