HTML CSS Bootstrap JavaScript jQuery MySQL PHP Data Mining

Bootstrap Colors

Written by RedoHub Team · Last updated: August 1, 2026

Bootstrap 5 provides a powerful semantic color palette. Instead of targeting specific hex codes in CSS, you apply color by telling Bootstrap the meaning of an element—like "success," "danger," or "warning."


1. Text Colors

You can change the color of any text instantly by using the .text-* utility classes.

.text-primary — Indicates an important or active item.

.text-secondary — Indicates a less important item.

.text-success — Indicates a successful or positive action.

.text-danger — Indicates a dangerous or negative action.

.text-warning — Indicates a warning that might need attention.

.text-info — Indicates neutral information.

.text-light — Light grey text (displayed on a dark background).

.text-dark — Dark grey text.

.text-body — The default body color (usually black/very dark grey).

.text-muted — Faded, muted grey text.

.text-white — Pure white text (displayed on a dark background).

<p class="text-success">Your payment was successful!</p>
<p class="text-danger">Error: Invalid password.</p>

2. Background Colors

Similar to text, you can color the background of any element (like a <div>, section, or table cell) using the .bg-* classes.

.bg-primary
.bg-secondary
.bg-success
.bg-danger
.bg-warning
.bg-info
.bg-light
.bg-dark
.bg-transparent
<div class="bg-primary text-white p-3">
    This block has a solid blue background.
</div>
Important Typography Rule: When using strong background colors (like .bg-primary, .bg-danger, or .bg-dark), always remember to pair it with .text-white so the text remains readable! Notice that .bg-warning is a very light yellow, so we use .text-dark with it instead.

3. Background Gradients

Bootstrap 5 includes a beautiful, subtle gradient utility. By adding the .bg-gradient class alongside your primary background color, Bootstrap generates a smooth linear gradient that instantly makes elements feel more premium and dimensional.

Flat Background
.bg-success
Gradient Background
.bg-success .bg-gradient
<!-- Applying the gradient effect -->
<div class="bg-primary bg-gradient text-white">
    Beautiful Gradient Element
</div>

Common Mistakes to Avoid

Pairing .bg-warning or .bg-light with .text-white. Both are light backgrounds — white text on top becomes nearly unreadable. Use .text-dark with light backgrounds and save .text-white for dark ones.
Relying on color alone to convey meaning. A red "danger" message that's only distinguishable by color fails accessibility guidelines for colorblind users — pair color with an icon or explicit text like "Error:".
Using .text-muted on a colored background. .text-muted is tuned for readability on white/light backgrounds — it can nearly disappear against a colored or dark background.

Try It: An Accessible Status Badge

A second example — combining a semantic background color with an icon so the meaning isn't conveyed by color alone:

<span class="badge bg-danger">
    <i class="fa-solid fa-circle-exclamation"></i> Failed
</span>
<span class="badge bg-success">
    <i class="fa-solid fa-circle-check"></i> Passed
</span>

Frequently Asked Questions

Q: Can I create my own custom color, like brand-purple?

A: Not through the CDN build alone — custom theme colors require compiling Bootstrap from its Sass source with your own color variables added to the theme map.

Q: What's the difference between .text-body and .text-dark?

A: .text-body uses your theme's default body text color (which could change if you customize it); .text-dark is a fixed dark gray regardless of body text settings.

Q: Does .bg-gradient work with every background color?

A: Yes — add it alongside any .bg-* class to apply a subtle gradient version of that same color. See the official Bootstrap Colors documentation for the full palette.