0
0
Tailwindmarkup~20 mins

Negative margin usage in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Negative Margin Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
layout
intermediate
2:00remaining
What is the visual effect of class="-mt-4" on an element?
Consider an element with a top margin of 1rem by default. What happens visually when you add -mt-4 in Tailwind CSS?
AThe element moves 1rem upwards, overlapping the element above it.
BThe element moves 1rem downwards, increasing space below it.
CThe element's top margin becomes 4rem, pushing it further down.
DThe element's margin is removed completely, so it sticks to the element above.
Attempts:
2 left
💡 Hint
Negative margin pulls the element closer or over the adjacent element in the specified direction.
selector
intermediate
2:00remaining
Which Tailwind class applies a negative left margin of 0.5rem?
You want to pull an element 0.5rem to the left using negative margin. Which class should you use?
A-mr-1
B-ml-2
C-ml-1
D-mr-2
Attempts:
2 left
💡 Hint
Check Tailwind's spacing scale where 1 equals 0.25rem, so 2 equals 0.5rem.
🧠 Conceptual
advanced
2:30remaining
What happens if you apply -mx-6 to a block element inside a container with padding?
A container has horizontal padding of 1.5rem. You apply -mx-6 to a block element inside it. What is the visual effect?
AThe element's left and right margins become negative 1.5rem, making it stretch outside the container edges.
BThe element's horizontal margins become positive 1.5rem, increasing space inside the container.
CThe element's width shrinks by 3rem, fitting inside the container padding.
DThe element's horizontal margins are removed, so it aligns exactly with the container padding.
Attempts:
2 left
💡 Hint
Negative horizontal margins pull the element outside its container's padding.
accessibility
advanced
2:30remaining
How can negative margins affect keyboard navigation and accessibility?
If an element is pulled visually over another using negative margins, what accessibility issue might occur?
ANegative margins improve accessibility by making elements easier to see.
BScreen readers might read the overlapped content twice, confusing users.
CKeyboard focus order might become confusing if elements visually overlap but are separate in the DOM.
DNegative margins have no effect on accessibility or keyboard navigation.
Attempts:
2 left
💡 Hint
Think about how visual position and DOM order can differ.
📝 Syntax
expert
3:00remaining
What error occurs if you write class="-m-4" in Tailwind CSS?
You want to apply a negative margin of 1rem on all sides but write class="-m-4". What happens?
ATailwind throws a build error because <code>-m-4</code> is not a valid class.
BThe element gets positive margin of 1rem on all sides.
CThe class is ignored and no margin is applied.
DTailwind applies negative margin of 1rem on all sides correctly.
Attempts:
2 left
💡 Hint
Check Tailwind's negative margin shorthand classes.