Why does the dark mode background not apply when system prefers dark mode?
medium
A. Because the prefix should be dark:, not darkmode:
B. Because darkMode must be set to 'class' instead of 'media'
C. Because bg-white overrides dark background always
D. Because Tailwind does not support dark mode with media queries
Solution
Step 1: Check dark mode prefix usage
The correct prefix for dark mode classes is dark:, not darkmode:.
Step 2: Effect of wrong prefix
Using darkmode:bg-black is invalid and ignored by Tailwind.
Final Answer:
Because the prefix should be dark:, not darkmode: -> Option A
Quick Check:
Use exact dark: prefix for dark mode [OK]
Hint: Use exactly dark: prefix, no variations [OK]
Common Mistakes:
Typing 'darkmode:' instead of 'dark:'
Changing config to 'class' unnecessarily
Assuming normal classes override dark mode
5. You want to create a responsive card that changes background color in dark mode only on screens wider than 768px using Tailwind with media-based dark mode. Which class combination achieves this?
hard
A. bg-white md:bg-gray-200 dark:bg-gray-800
B. bg-white dark:md:bg-gray-800
C. bg-white dark:bg-gray-800 md:bg-gray-200
D. bg-white md:dark:bg-gray-800
Solution
Step 1: Understand responsive and dark mode prefixes
Tailwind applies prefixes from left to right: md:dark: means dark mode styles apply only on medium screens and up.
Step 2: Analyze each option
bg-white md:dark:bg-gray-800 uses md:dark:bg-gray-800 which applies dark background only on screens ≥768px and in dark mode.
Final Answer:
bg-white md:dark:bg-gray-800 -> Option D
Quick Check:
Use md:dark: to combine media query and dark mode [OK]
Hint: Chain prefixes: screen size first, then dark mode [OK]
Common Mistakes:
Reversing prefix order like 'dark:md:'
Applying dark mode without screen size condition
Using unrelated classes that override styles
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.