Rule 11.1.2

Summary

This rule checks that each <label> element with a for attribute references an existing form field via its id attribute.

Business description

Criterion

11.1

Test

11.1.2

Description

Chaque champ de formulaire associé à une balise <label> ayant un attribut for, vérifie-t-il ces conditions ?

Level

A

Technical description

Scope

Page

Decision level

Decidable

Algorithm

Selection

Set1

All <label> elements with a for attribute:

label[for]

Process

Test1

For each element in Set1, check that the value of the for attribute matches the id attribute of an existing element in the page.

For each element returning false in Test1, raise a MessageA.

MessageA: Label for missing form field
  • code: LabelForMissingFormField
  • status: Failed
  • parameter: for attribute value, tag name
  • present in source: yes

Analysis

Passed

All <label> elements with a for attribute reference an existing element with a matching id (Test1 returns true for all elements in Set1).

Failed

At least one <label> element with a for attribute does not reference any existing element (Test1 returns false for at least one element in Set1).

Not Applicable

The page has no <label> element with a for attribute (Set1 is empty).

Files