0
0
HTMLmarkup~20 mins

Labels and placeholders in HTML - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Label and Placeholder Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Why use
What is the main benefit of using a
AIt hides the input field from the user.
BIt changes the input field's background color automatically.
CIt disables the input field until the label is clicked.
DIt improves accessibility by allowing screen readers to identify the input purpose.
Attempts:
2 left
💡 Hint
Think about users who rely on assistive technology.
📝 Syntax
intermediate
1:30remaining
Correct syntax for linking label to input
Which option correctly links a label to an input field with id='email'?
A<label for="email">Email:</label><input id="email" type="email">
B<label for="email">Email:</label><input type="email">
C<label>Email:<input id="email" type="email"></label>
D<label id="email">Email:</label><input for="email" type="email">
Attempts:
2 left
💡 Hint
The 'for' attribute in label must match the input's id.
rendering
advanced
2:00remaining
Visual difference between placeholder and label
What will the user see when the input below is rendered in a browser?

<label for="name">Name:</label><input id="name" type="text" placeholder="Enter your full name">
AThe label 'Name:' appears outside the input box, and the placeholder text 'Enter your full name' appears inside the input box until typed over.
BOnly the placeholder text 'Enter your full name' appears inside the input box; the label is hidden.
CThe label text appears inside the input box as default text, and the placeholder is ignored.
DNeither label nor placeholder text appears; the input box is empty.
Attempts:
2 left
💡 Hint
Labels appear outside inputs; placeholders appear inside inputs as hints.
selector
advanced
1:30remaining
CSS selector for styling placeholder text
Which CSS selector correctly styles the placeholder text color to gray for all input fields?
Ainput.placeholder { color: gray; }
Binput:placeholder { color: gray; }
Cinput::placeholder { color: gray; }
Dinput::place { color: gray; }
Attempts:
2 left
💡 Hint
Look for the double colon syntax for pseudo-elements.
accessibility
expert
2:00remaining
Accessibility issue with placeholder-only inputs
What is the main accessibility problem if a form input uses only a placeholder without a label?
AThe placeholder text will never disappear when typing.
BScreen readers may not announce the input's purpose, making it hard for visually impaired users to understand the form.
CThe input will be disabled by default.
DThe input will automatically submit the form on focus.
Attempts:
2 left
💡 Hint
Think about how screen readers read form fields.