Challenge - 5 Problems
Button Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ā rendering
intermediate2:00remaining
What will this button look like in the browser?
Given this Tailwind CSS button code, what is the visual style you will see when rendered?
Tailwind
<button class="bg-blue-600 hover:bg-blue-700 text-white font-semibold py-2 px-4 rounded">Click me</button>Attempts:
2 left
š” Hint
Look at the background and text color classes, and the hover prefix.
ā Incorrect
The class bg-blue-600 sets a medium blue background, text-white makes the text white, rounded adds rounded corners, and hover:bg-blue-700 changes the background to a darker blue when hovered.
ā selector
intermediate1:30remaining
Which Tailwind class applies padding inside a button?
You want to add vertical and horizontal padding inside a button. Which class correctly adds 0.5rem vertical and 1rem horizontal padding?
Attempts:
2 left
š” Hint
Tailwind uses 'py' for vertical padding and 'px' for horizontal padding.
ā Incorrect
In Tailwind, 'py-2' means padding-top and padding-bottom of 0.5rem, and 'px-4' means padding-left and padding-right of 1rem.
š§ Conceptual
advanced2:30remaining
Why use 'focus:outline-none' with 'focus:ring' on buttons?
Consider this button code snippet:
Why is it important to use both 'focus:outline-none' and 'focus:ring' classes together?
<button class="focus:outline-none focus:ring-2 focus:ring-blue-500">Press</button>
Why is it important to use both 'focus:outline-none' and 'focus:ring' classes together?
Attempts:
2 left
š” Hint
Think about keyboard users and visible focus indicators.
ā Incorrect
Removing the default outline without adding a visible focus style harms accessibility. Using 'focus:ring' adds a clear ring so keyboard users can see focus.
ā layout
advanced2:30remaining
How to center a button horizontally and vertically inside a container?
You have a container div and a button inside it. Which Tailwind classes on the container will center the button both horizontally and vertically?
Tailwind
<div class="???"> <button class="bg-green-500 text-white px-4 py-2 rounded">Submit</button> </div>
Attempts:
2 left
š” Hint
Use flexbox to center items both ways.
ā Incorrect
'flex' makes the container a flexbox, 'items-center' centers vertically, 'justify-center' centers horizontally, and 'h-64' gives height so centering is visible.
ā accessibility
expert3:00remaining
Which button code is most accessible for screen readers and keyboard users?
Choose the button code that best supports accessibility:
Attempts:
2 left
š” Hint
Consider semantic elements and ARIA labels.
ā Incorrect
Using a