Explore your understanding of responsive design using utility-first classes with this focused quiz on Tailwind CSS principles. Enhance your skills in building adaptable layouts, fluid typography, and device-specific styling through practical, scenario-driven questions optimized for responsive web development.
Which utility class correctly applies a background color only on devices with a width equal to or greater than the 'md' breakpoint?
Explanation: The correct answer is md:bg-blue-500, which follows the standard syntax for breakpoint prefixes in utility-first frameworks. bg-md-blue-500 and bg-blue-500-md are not valid class structures and will not apply the style as intended. medium:bg-blue-500 is an incorrect prefix format and does not correspond to any recognized breakpoint.
What is the default behavior when you use the class text-lg without any responsive prefix in a responsive utility framework?
Explanation: Adding text-lg without a prefix applies the style globally, which means all breakpoints inherit the class unless a more specific, responsive utility is defined. The class does not restrict itself to large screens, nor is it ignored on mobile devices. It does not uniquely target the range between small and medium breakpoints unless you specify such prefixes.
If you want a grid layout with one column on small screens and three columns on large screens, which class combination would you use?
Explanation: grid-cols-1 lg:grid-cols-3 properly sets one column by default and switches to three columns at the large breakpoint. col-1-3-xl and grid-sm-1 lg-grid-3 are not valid class names. lg:grid-col-3 sm:grid-col-1 incorrectly formats the class structure and does not represent recognized utility syntax.
How would you hide a button on medium and larger screens while keeping it visible on smaller screens?
Explanation: md:hidden hides the element on medium and larger screens according to the correct responsive utility convention. hidden:md and md:hide are not valid class names, while hide-md does not correspond to any recognized responsive syntax.
Which class combination would you use to set horizontal padding of 4 units on small screens and increase it to 8 units on extra-large screens?
Explanation: px-4 xl:px-8 sets the default horizontal padding to 4 units on all screens and increases it to 8 units only on extra-large screens, following the appropriate syntax. p-4 xl:p-8 adjusts all padding, not just horizontal. pxs-4 xl-px-8 and xl:px-8 px-4 either use incorrect prefixes or are not valid class combinations.