Skip to content

fix(a11y): associate search form labels with their inputs - #1354

Open
NakuRei wants to merge 1 commit into
CaiJimmy:masterfrom
NakuRei:fix/search-label-association
Open

fix(a11y): associate search form labels with their inputs#1354
NakuRei wants to merge 1 commit into
CaiJimmy:masterfrom
NakuRei:fix/search-label-association

Conversation

@NakuRei

@NakuRei NakuRei commented Sep 1, 2026

Copy link
Copy Markdown

What

Add for and id attributes to the search forms on the 404 page, the search page and the search widget so that each <label> is associated with its <input>.

Why

The labels are rendered as siblings of the inputs without a for attribute, so they are not associated with the inputs. Clicking the label does not focus the input, and Chrome DevTools lists the label under Improvements in the Issues panel as "No label associated with a form field".

Notes

  • The labels keep their absolute positioning, so the visual output is identical.
  • The input in 404.html already has id="searchInput", which its inline script depends on, so only the for attribute is added there.
  • The two new ids (search-page-input, search-widget-input) use kebab-case like the other ids in the theme.

Testing

Checked the 404 page, the search page and the homepage with the search widget in Chrome, before and after the change.

  • Before: label.control is null, clicking the label leaves focus on <body>, and the Issues panel reports the label on all three pages.
  • After: label.control is the search input, clicking the label focuses the input, and the Issues panel no longer reports the label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant