Menu
CoddyTech

Combining Utilities

Part of the Fundamentals section of Coddy's Tailwind CSS journey. Lesson 3 of 55.

A library notice can combine px-4 with bg-black text-white. The first utility adds 16 pixels of left and right padding; the other two set background and text colors. Each utility handles a separate property.

<div class="bg-black text-white px-4">Museum sample</div>

Separate class names with spaces. Avoid two unprefixed utilities that set the same property: their order in the HTML is not a dependable override mechanism because generated CSS order decides the cascade. Numeric spacing uses a 0.25rem unit, normally 4 pixels: multiply the utility number by 4 to find the pixel spacing.

challenge icon

Challenge

Easy

Give the supplied event banner 24 pixels of horizontal padding. Preserve its black background and white text.

Keep the supplied content and element IDs. Edit the HTML utility classes or the requested CSS. Click Run preview to refresh the preview after edits, then use Check/Run code to grade your work.

Try it yourself

<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Practice studio</title><link rel="stylesheet" href="./styles.css"></head><body>
<div id="target" class="bg-black text-white">Open studio</div>
</body></html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals