Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 1.19 KB

File metadata and controls

43 lines (31 loc) · 1.19 KB
id input-requires-label
title input-requires-label
description Requires every <input> element to have an associated <label> for accessibility compliance.
keywords
input
label
accessibility

import { Badge } from '@astrojs/starlight/components';

All <input> tags must have a corresponding <label> tag.

Level:

Config value

  • true: enable rule
  • false: disable rule

The following patterns are considered rule violations

<input type="password">
<input id="some-id" type="password" /> <label for="some-other-id"/>
<input id="some-id" type="password" /> <label for=""/>
<input type="password" /> <label for="something"/>

The following patterns are not considered rule violations

<label for="some-id"/><input id="some-id" type="password" />
<input id="some-id" type="password" /> <label for="some-id"/>
<label>Password <input type="password" /></label>

Why this rule is important

This rule ensures that the input element has a corresponding label element for accessibility compliance.

Further reading: Axe Rules - input elements must have labels