org.sonar.l10n.web.rules.Web.FieldsetWithoutLegendCheck.html Maven / Gradle / Ivy
The newest version!
For users of assistive technology such as screen readers, it may be challenging to know what is expected in each form's input.
The input's label alone might not be sufficient: 'street' could be part of a billing or a shipping address for instance.
Fieldset legends are read out loud by screen readers before the label each time the focus is set on an input.
For example, a legend 'Billing address' with a label 'Street' will read 'Billing address street'.
Legends should be short, and 'Your' should not be repeated in both the legend and the label, as it would result in 'Your address Your City' being read.
Noncompliant Code Example
<fieldset> <!-- Non-Compliant -->
Street: <input type="text"><br />
Town: <input type="text"><br />
Country: <input type="text"><br />
</fieldset>
Compliant Solution
<fieldset> <!-- Compliant -->
<legend>Billing address</legend>
Street: <input type="text"><br />
Town: <input type="text"><br />
Country: <input type="text"><br />
</fieldset>