What is the purpose of a <label> element in HTML forms?
The <label> element describes a form control, making it easier for users and assistive technologies to understand what input is expected. It improves accessibility and usability.
Click to reveal answer
beginner
How does the <label> element associate with an input field?
You can link a <label> to an input by using the 'for' attribute with the input's id, or by wrapping the input inside the <label> element.
Click to reveal answer
beginner
What is a placeholder attribute in an input field?
The placeholder attribute shows a short hint inside the input box to guide users on what to enter. It disappears when the user starts typing.
Click to reveal answer
intermediate
Why should you not rely only on placeholders instead of labels?
Placeholders disappear when typing and may not be read by screen readers, so labels are essential for accessibility and clarity.
Click to reveal answer
intermediate
How do labels improve keyboard navigation?
Clicking a label focuses the associated input, making it easier to select fields without using a mouse, which helps keyboard users.
Click to reveal answer
Which attribute links a <label> to an input field?
Aid
Bname
Cfor
Dplaceholder
✗ Incorrect
The 'for' attribute on a
What happens to placeholder text when you start typing in the input?
AIt stays visible
BIt moves below the input
CIt turns bold
DIt disappears
✗ Incorrect
Placeholder text disappears as soon as the user types in the input field.
Why are labels important for screen readers?
AThey provide descriptive text for inputs
BThey make inputs bigger
CThey add color
DThey hide inputs
✗ Incorrect
Labels give screen readers the text to announce what the input is for.
Which is a correct way to associate a label with an input?