Bootstrap Colors & Backgrounds

Bootstrap Framework 10 min min read Updated: Nov 16, 2026 Beginner
Bootstrap Colors & Backgrounds
Beginner Topic 3 of 11

Theme Colors

Bootstrap has a built-in set of named colors. Each color has a meaning, which makes your design consistent.

NameTypical Meaning
primaryMain action or brand color (blue)
secondaryLess important, supporting (gray)
successPositive or completed (green)
dangerError or delete (red)
warningBe careful (yellow)
infoInformation (light blue)
lightLight gray or white
darkAlmost black

Text Colors

html <p class="text-primary">Primary text</p> <p class="text-success">Success text</p> <p class="text-danger">Danger text</p> <p class="text-warning">Warning text</p> <p class="text-body-secondary">Muted text</p> <p class="text-white bg-dark">White text on dark</p>

Background Colors

html <div class="p-3 bg-primary text-white">Primary background</div> <div class="p-3 bg-success text-white">Success background</div> <div class="p-3 bg-light">Light background</div>

The text-bg Helper

Picking a readable text color for each background is easy to forget. The text-bg-* class sets both the background and a matching text color together.

html <div class="p-3 text-bg-primary">Primary with the right text color</div> <div class="p-3 text-bg-warning">Warning with dark text</div>

Subtle Colors

Soft versions of the theme colors are perfect for calm backgrounds, notices and cards.

html <div class="p-3 bg-success-subtle text-success-emphasis"> A soft green message </div> <div class="p-3 bg-danger-subtle border border-danger-subtle"> A soft red message </div>

Opacity

html <div class="bg-primary bg-opacity-25 p-3">25% blue</div> <div class="bg-primary bg-opacity-50 p-3">50% blue</div> <div class="text-primary text-opacity-50">Half-transparent text</div>

Gradient

html <div class="bg-primary bg-gradient text-white p-4"> Primary with a soft gradient </div>

Link Colors

html <a href="#" class="link-primary">Primary link</a> <a href="#" class="link-danger">Danger link</a>
Accessibility tip: Always keep good contrast between text and background. Dark text on a light yellow bg-warning is readable, but white text on yellow is not.
Result

Colored text lines, solid and soft colored blocks, and one block with a gradient shine.

Conclusion

Bootstrap colors help you build a consistent, professional palette. Choose colors by meaning and use subtle variants for a modern, gentle look.

Quick Summary: text-*, bg-*, text-bg-*, *-subtle, bg-opacity-* and bg-gradient style your colors without writing CSS.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators