Challenge - 5 Problems
Active and Focus States Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ selector
intermediate2:00remaining
Identify the selector for keyboard focus
Which CSS selector correctly styles an element when it receives keyboard focus?
Attempts:
2 left
💡 Hint
Think about which state applies when you tab to an element.
✗ Incorrect
The :focus selector applies styles when an element receives keyboard focus, such as when tabbing through links or form controls.
🧠 Conceptual
intermediate2:00remaining
Purpose of :active state
What does the
:active CSS pseudo-class represent?Attempts:
2 left
💡 Hint
Think about the moment you press down on a button.
✗ Incorrect
The :active state applies while the user is pressing down on an element, such as clicking a button or link.
❓ rendering
advanced2:00remaining
Visual difference between :focus and :active
Given this CSS, what color will the button text be when it is focused but not pressed?
CSS
button:focus { color: blue; } button:active { color: red; }
Attempts:
2 left
💡 Hint
Focus and active states can have different styles; only one applies at a time.
✗ Incorrect
When the button is focused but not pressed, only :focus applies, so the text color is blue.
❓ accessibility
advanced2:00remaining
Why is visible focus important?
Why should web developers always provide a visible focus style for interactive elements?
Attempts:
2 left
💡 Hint
Think about users who navigate without a mouse.
✗ Incorrect
Visible focus helps keyboard users see which element is currently selected, improving accessibility.
📝 Syntax
expert2:00remaining
Identify the error in this CSS for active and focus states
What error does this CSS cause?
button:focus, :active { background: yellow; }CSS
button:focus, :active { background: yellow; }
Attempts:
2 left
💡 Hint
Check if all selectors have an element or class before the pseudo-class.
✗ Incorrect
The selector :active without an element or class is invalid in this context and causes a syntax error. It should be button:active to target buttons.