Hint: mx sets horizontal, my sets vertical margins with scale values [OK]
Common Mistakes:
Mixing horizontal and vertical values
Assuming mx-6 means 6rem margin
Thinking mx-6 and my-2 override each other
4. You want to add margin only to the bottom of an element using Tailwind CSS, but your code mb8 does not work. What is the correct fix?
medium
A. Change mb8 to bottom-m-8
B. Change mb8 to m-b-8
C. Change mb8 to margin-bottom-8
D. Change mb8 to mb-8
Solution
Step 1: Identify Tailwind margin bottom syntax
Tailwind margin bottom classes require a dash between prefix and scale number, like mb-8.
Step 2: Correct the missing dash error
The code mb8 is invalid because it lacks the dash. Adding the dash fixes the syntax.
Final Answer:
Change mb8 to mb-8 -> Option D
Quick Check:
Margin bottom class needs dash: mb-8 [OK]
Hint: Always use dash between property and value in Tailwind classes [OK]
Common Mistakes:
Omitting dash between prefix and number
Using invalid class formats like m-b-8
Trying full CSS property names as classes
5. You want to create a responsive layout where an element has no margin on small screens, but margin of 3rem on the left and right on medium screens and above. Which Tailwind classes achieve this?
hard
A. mx-0 md:m-12
B. m-0 md:mx-12
C. m-0 md:ml-12 md:mr-12
D. m-0 md:mx-3rem
Solution
Step 1: Understand responsive prefix usage
In Tailwind, md: prefix applies styles at medium screen sizes and above.
Step 2: Apply zero margin on all sides for small screens
m-0 sets margin 0 on all sides for small screens.
Step 3: Apply horizontal margin 3rem on medium screens
mx-12 sets horizontal margin to spacing scale 12 = 3rem. Using md:mx-12 applies this only on medium+ screens.
Final Answer:
m-0 md:mx-12 -> Option B
Quick Check:
m-0 no margin small, md:mx-12 horizontal 3rem medium+ [OK]
Hint: Use m-0 for small, md:mx-12 for medium+ horizontal margin [OK]
Common Mistakes:
Using invalid units like 3rem directly in class
Applying margin on all sides instead of horizontal only
Mixing up responsive prefixes and margin directions