Text color utilities help you change the color of text easily. This makes your website look nice and clear.
Text color utilities in Tailwind
Start learning this pattern below
Jump into concepts and practice - no test required
text-{color}-{shade}{color} is the color name like red, blue, green, etc.
{shade} is the number that shows how light or dark the color is, usually from 50 (light) to 900 (dark).
text-red-500
text-blue-700
text-green-300
text-gray-900
This example shows four lines of text, each with a different Tailwind text color utility. You can see how the text color changes based on the class used.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Text Color Utilities Example</title> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="p-6"> <h1 class="text-red-500">This text is red</h1> <p class="text-blue-700">This text is dark blue</p> <p class="text-green-300">This text is light green</p> <p class="text-gray-900">This text is very dark gray</p> </body> </html>
You can combine text color utilities with other Tailwind classes for spacing, font size, and more.
Use colors that have good contrast with the background for easy reading.
Tailwind colors follow a scale from 50 (lightest) to 900 (darkest).
Text color utilities let you quickly change text colors using simple class names.
Use text-{color}-{shade} format to pick the color and shade.
Choose colors that make your text easy to read and visually appealing.
Practice
text-red-500 do to the text?Solution
Step 1: Understand Tailwind text color syntax
The classtext-red-500uses the formattext-{color}-{shade}to set text color.Step 2: Interpret the color and shade
Here,redis the color and500is a medium shade, so it changes text color to medium red.Final Answer:
Changes the text color to a medium shade of red -> Option AQuick Check:
text-red-500 sets medium red text color [OK]
- Confusing text color with background color
- Thinking it changes font weight
- Assuming it adds underline
Solution
Step 1: Recall Tailwind shade numbering
Lower numbers like 100 mean lighter shades, higher numbers like 900 mean darker shades.Step 2: Identify correct syntax for light blue text
text-blue-100is the correct format for light blue text color.Final Answer:
text-blue-100 -> Option CQuick Check:
Light shade uses 100 number [OK]
- Using invalid class names like text-light-blue
- Confusing shade numbers (900 is dark)
- Mixing background and text color classes
<p class="text-green-700">Hello</p>
Solution
Step 1: Analyze the class name
The classtext-green-700sets the text color to green with shade 700, which is a darker shade.Step 2: Match shade to color intensity
Shade 700 is darker than 500 or 400, so the text will appear dark green.Final Answer:
A dark green color -> Option AQuick Check:
Shade 700 means dark color [OK]
- Assuming 700 is light shade
- Mixing green with blue or red
- Ignoring the shade number
<span class="text-purple-">Sample</span>
Solution
Step 1: Check the class syntax
The classtext-purple-ends with a dash but no shade number, which is invalid.Step 2: Confirm correct usage
Tailwind requires a shade number like 100, 500, 700 after the color name for text color classes.Final Answer:
Missing shade number after color name -> Option BQuick Check:
Shade number is required after color [OK]
- Leaving out the shade number
- Confusing text and background classes
- Thinking any element can't have text color
Solution
Step 1: Understand contrast needs on dark backgrounds
Light text colors are easier to read on dark backgrounds, so a light gray or white is best.Step 2: Evaluate the options
text-gray-100is a very light gray, suitable for dark backgrounds.text-gray-900andtext-blackare dark colors, hard to read on dark backgrounds.text-white-500is invalid because white doesn't have shades.Final Answer:
text-gray-100 -> Option DQuick Check:
Light colors for dark backgrounds [OK]
- Using dark text on dark backgrounds
- Assuming white has shade numbers
- Confusing background and text colors
