Performance: Breakpoint prefixes (sm, md, lg, xl, 2xl)
Breakpoint prefixes affect how CSS rules apply at different screen sizes, impacting rendering and layout recalculations during resizing.
class="p-4 m-4 text-center sm:text-lg sm:bg-blue-500"class="p-4 m-4 text-center text-lg bg-blue-500"| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No breakpoint prefixes (all styles apply always) | Minimal | Multiple on resize | Higher due to layout shifts | [X] Bad |
| Using breakpoint prefixes to scope styles | Minimal | Single or fewer on resize | Lower due to stable layout | [OK] Good |
md: prefix in Tailwind CSS do?md: apply styles starting from that screen size and up.md: meansmd: applies styles on medium screens (768px) and larger devices.lg:text-center.lg:text-center uses correct prefix + utility format.<div class="text-left md:text-center lg:text-right">Hello</div>
lg:text-right applies, overriding smaller breakpoints.sm:bg-red-500 md:bg-green-500 lg:bg-blue-500. But on a 500px wide screen, the background is still blue. What is the likely problem?lg:bg-blue-500 class is applying at all screen sizes, which is incorrect behavior.lg: prefix is missing the colon or is malformed, causing the class to be interpreted as a normal class and applied globally.lg: prefix applies to all screen sizes -> Option Dp-2 applies to all screens, then md:p-4 overrides on medium (tablet) and up, lg:p-6 overrides on large (desktop) and up.p-2 md:p-4 lg:p-6 correctly sets small padding base, medium padding at md, and large padding at lg.Pass the test and this pattern moves unknown