Text colors
Text colour utilities colour text and pair well with background utilities for accessible contrast.
In this page:
Syntax
<p class="text-primary">text</p>
<p class="text-danger-emphasis">text</p>
<p class="text-body-secondary">text</p>
Text colors
The same theme colours are available as text-* classes, with -emphasis variants for stronger contrast and text-body-* for neutral shades. Use text-white or text-dark to fix contrast on coloured backgrounds. text-opacity-* softens the colour.
Note:
Check contrast; text-warning on white is hard to read.
Example: Text colors
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="container">
<p class="text-primary">text-primary</p>
<p class="text-danger-emphasis">text-danger-emphasis</p>
<div class="bg-dark p-2"><span class="text-white">white on dark</span> <span class="text-white text-opacity-50">50% opacity</span></div>
</div>
</body>
</html>
Live Example
Related Topics
Common Mistakes
- Low contrast such as yellow on white
- Using text-muted where dark mode support matters
- Mixing many colours
Chapter Summary
- text-{theme} colours text
- -emphasis variants add contrast
- text-white and text-dark fix contrast
- text-opacity softens text
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: