Form field must not have multiple label elements
How to Fix the Problem
Ensure that only one label is assigned to a form field.
Correct markup solutions
The form-field-multiple-labels
rule contains five markup
patterns that pass analysis:
<label for="pass1">Label</label>
<input type="text" id="pass1" />
<textarea id="pass2" title="Label"></textarea>
<label>First Name: <input type="text" id="pass3" /></label>
<label>Choose an option:
<select id="pass4">
<option selected="selected">Chosen</option>
<option>Not Selected</option>
</select>
</label>
<label>Enter your comments:
<textarea id="pass5"></textarea>
</label>
Caution: Screen Reader and Browser Combinations Inconsistently Support
Multiple form
Element Labels
The following markup examples work across the following screen reader and browser combinations documented here as of the axe-core 3.4.0 release. See Multiple Labels on a Single Input for further information on screen reader and browser testing combinations.
<input type="checkbox" id="D" aria-labelledby="E"/>
<label for="D" aria-hidden="true">Please</label>
<label for="D" id="E">Excuse</label>
<input type="checkbox" id="F" aria-labelledby="G H"/>
<label for="F" id="G" aria-hidden="true">Please</label>
<label for="F" id="H">Excuse</label>
<input type="checkbox" id="I"/>
<label for="I" style="display:none">Please</label>
<label for="I">Excuse</label>
Confirm the existence of one visible label per form element. to achieve
correct functionality across most screen reader and browser combinations.
Using the aria-hidden
attribute alone is not sufficient and you
need to hide additional labels using CSS.
Incorrect markup examples
The form-field-multiple-labels
rule contains nine markup
patterns that fail analysis:
<label for="fail1">Hi</label>
<label for="fail1">Foo</label>
<input type="text" id="fail1" />
<label for="fail2">label one</label>
<label for="fail2">label two</label>
<input type="checkbox" id="fail2" />
<label for="fail3" id="l1">label one</label>
<label for="fail3">label two</label>
<input type="checkbox" id="fail3" aria-labelledby="l1" />
<label for="fail4">First Name:</label>
<label>First Name:
<input type="text" id="fail4" />
</label>
<label for="fail5">Choose an option:</label>
<label>Choose an option:
<select id="fail5">
<option selected="selected">Chosen</option>
<option>Not Selected</option>
</select>
</label>
<label for="fail6">Enter your comments:</label>
<label>Enter your comments:
<textarea id="fail6"></textarea>
</label>
<label>Enter your comments:
<label>Enter your comments:
<textarea id="fail7"></textarea>
</label>
</label>
<label>Enter your comments:
<label>Enter your comments:
<label>Enter your comments:
<textarea id="fail8"></textarea>
</label>
</label>
</label>
<label for="fail9">Enter your comments:</label>
<label>Enter your comments:
<label>Enter your comments:
<label>Enter your comments:
<textarea id="fail9"></textarea>
</label>
</label>
</label>
Why it Matters
Assigning multiple labels to the same form field can cause problems for some combinations of screen readers and browsers, and the results are inconsistent from one combination to the next. Some combinations will read the first label. Some will read the last label. Others will read both labels.
Rule Description
Ensures form field does not have multiple labels.
The Algorithm (in simple terms)
Ensures form field does not have multiple labels.
"; if (!!window.MSInputMethodContext && !!document.documentMode ) document.getElementById("form_message").innerHTML = checkMark + msg + "
"; else document.getElementById("form_message").innerHTML = checkMarkAnimation + msg + "
"; } if(type === "warning" ) { document.getElementById("form_message").style.color = "#916216"; document.getElementById("form_message").innerHTML = warningIcon + msg + "
"; } if(type === "error" ) { document.getElementById("form_message").style.color = "#b40909"; document.getElementById("form_message").innerHTML = errorIcon + msg + "
"; } document.getElementById("form_message").tabIndex = -1; document.getElementById("form_message").focus(); } function clearMessage() { document.getElementById("form_message").innerHTML = ""; } function showFeedbackForm() { document.getElementById("feedback-form").className = ""; document.getElementById("feedback-info").className = "deque-hidden"; document.getElementById("yesButton").focus(); setTimeout((function (){ document.getElementById("yesButton").focus(); }), 5000); } function hideFeedbackForm() { if( feedbackData ) { document.getElementById("feedback-info").className = ""; showMessage("You have cancelled editing your earlier feedback.", "warning"); } document.getElementById("feedback-form").className = "deque-hidden"; document.getElementById("yesButton").style.display = ""; document.getElementById("noButton").style.display = ""; document.getElementById("noFeedback").className = "deque-hidden"; setTimeout((function() { clearMessage(); }), 4000); }