Performance: Background color utilities
Background color utilities affect paint time and visual stability during page load and interactions.
Jump into concepts and practice - no test required
<div class="bg-blue-500">Content</div><div class="bg-red-500 bg-green-500 bg-blue-500">Content</div>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple conflicting bg color classes | No extra DOM nodes | 0 | Multiple paints due to style conflicts | [X] Bad |
| Single bg color utility class | No extra DOM nodes | 0 | Single paint | [OK] Good |
| Bg color with opacity utility | No extra DOM nodes | 0 | Extra paint layers | [! ] OK |
| Direct RGBA background color | No extra DOM nodes | 0 | Single paint layer | [OK] Good |
bg-blue-500 do to an element?bg- in Tailwind CSS means background color.blue-500 is a medium shade of blue in Tailwind's color palette.bg-{color}-{shade} with dashes.bg-red-300 matches the correct syntax exactly.<div class="bg-green-700 p-4">Hello</div>
bg-green-700 sets the background color to green with shade 700.<div class="bg-yellow400 p-2">Warning</div>
bg-yellow400 is missing a dash between color and shade.<button class="?">Click me</button>
bg-blue-600 and hover:bg-blue-400, which means background lightens on hover.