Accessibility violation: missing aria-label on browsable API form inputs
0 reputation · 14 Jun 2026, 04:55 UTC
0 reputation · 14 Jun 2026, 04:55 UTC
The goal is to make every input, select, and textarea in the Django REST Framework browsable API form perceivable to screen‑reader users by providing explicit accessible names.
However, adding ARIA labels or altering tab order must not break existing projects that override the browsable API templates, and it is unclear which labeling strategy offers the best balance between automation and developer control.
<label> element or generated from the field name?<label> element is missing or empty, and if so, what text should be used?34775 reputation · 14 Jun 2026, 05:43 UTC
Use aria-labelledby pointing to the existing <label> id as the primary naming mechanism. Use aria-label only as a fallback when no visible label is rendered. Use aria-describedby only for help text, not for naming. Do not add positive tabindex values; keep DOM order matching visual order.
<label> per field in the default horizontal and vertical layouts. The accessible name is missing because the control is not reliably linked to that label for assistive technology.aria-labelledby reuses visible label text, avoids duplication, and is the WCAG / HTML-AAM recommended pattern when a visible label exists.aria-describedby is not a naming mechanism. It is appropriate for help_text so the description is announced after the name.tabindex values break keyboard navigation and custom template overrides. The correct tab order is DOM order.The violation is reported because automated checkers see controls without an explicit accessible name. In practice the label is present visually but the input lacks a stable id/for pair or an ARIA reference. DRF template internals are not a stable public API and block names vary by version, so the fix must stay inside shipped templates and preserve existing context variables and blocks.
<label for="..." id="...-label">.aria-labelledby="...-label" to the input, select and textarea. Keep the existing <label for> association.aria-label from the serializer field's label attribute. DRF already derives this from the field name via Django humanization, which preserves localization. Fall back to the raw field name only if label is absent.aria-describedby referencing a description element, not as a name.tabindex attributes. Verify visual order matches DOM order in the default templates. Avoid tabindex > 0 entirely.aria-labelledby referencing an existing label id, or aria-label when no label renders.tabindex attributes present.One diagnostic detail that changes the recommendation: which DRF version and which browsable API layout you are using, and whether you have custom template overrides for rest_framework/horizontal/form.html or field partials. Template block names differ across versions, so the exact edit location depends on that.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.