0
0
HTMLmarkup~5 mins

Labels and placeholders in HTML - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
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
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
Why are labels important for screen readers?
AThey provide descriptive text for inputs
BThey make inputs bigger
CThey add color
DThey hide inputs
Which is a correct way to associate a label with an input?
A<label>Email<input></label>
BBoth B and C
C<label for='email'>Email</label><input id='email'>
DNeither B nor C
Can placeholders replace labels for accessibility?
ANo, labels are needed
BYes, always
COnly on mobile
DOnly for passwords
Explain how to properly use labels and placeholders in a form for best accessibility.
Think about how users and assistive tools understand form fields.
You got /4 concepts.
    Describe the difference between a label and a placeholder and why both are important.
    Consider what happens when you start typing and how screen readers work.
    You got /4 concepts.