Menu
CoddyTech

Text and Background

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

A label can pair text-white with bg-black. The text prefix changes foreground color, while the background prefix paints the box behind it. Palette names such as red-500 combine a family with a shade.

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

A foreground and background must be readable together. Do not use color as the only status signal: keep a written label such as Open or Closed so the meaning survives when colors are hard to distinguish. The same family/shade pattern works for green, blue and red: replacing the family and shade selects another palette entry.

challenge icon

Challenge

Easy

Color the Open status with the green palette shade 700. Keep the word Open and the white background.

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-white">Open</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