Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Bootstrap5 Colors

Bootstrap5 Colors

Bootstrap 5 provides some meaningful color classes: .text-muted, .text-primary, .text-success, .text-info, .text-warning, .text-danger, .text-secondary, .text-white, .text-dark, .text-body (default color, which is black) and .text-light:

Example

<div class="container">
<h2>

Text Colors with Specific Meanings

h2

<p class="text-muted">

Muted text.

p

<p class="text-primary">

Important text.

p

<p class="text-success">

Text for successful actions.

p

<p class="text-info">

Text representing informational messages.

p

<p class="text-warning">

Warning text.

p

<p class="text-danger">

Danger text.

p

<p class="text-secondary">

Subheading.

p

<p class="text-dark">

Dark gray text.

p

<p class="text-body">

The default color is black.

p

<p class="text-light">

Light gray text (hard to see on a white background).

p

<p class="text-white">

White text (hard to see on a white background).

p

div

Try it »

You can set the text color opacity to 50% using the .text-black-50 or .text-white-50 classes:

Example

<p class="text-black-50">

Black text with 50% opacity, on a white background.

p

<p class=">

text-white-50 bg-dark

"

White text with 50% opacity, on a black background.

p

Try it »

Using in Links

Example

<div class="container">
<h2>

Text Colors

h2

<

p

Mouse over the link.

p

<a href="" class="text-muted">

Muted link.

a

<a href="" class="text-primary">

Primary link.

a

<a href="" class="text-success">

Success link.

a

<a href="" class="text-info">

Informational text link.

a

<a href="" class="text-warning">

Warning link.

a

<a href="" class="text-danger">

Danger link.

a

<a href="" class="text-secondary">

Subheading link.

a

<a href="" class="text-dark">

Dark gray link.

a

<a href="" class="text-light">

Light gray link.

a

div

Try it »


Background Color

The classes providing background colors are: .bg-primary, .bg-success, .bg-info, .bg-warning, .bg-danger, .bg-secondary, .bg-dark and .bg-light.

Note that background colors do not set the text color; in some examples you need to use them together with .text-* classes.

Example

<div class="container">
<h2>

Background Color

h2

<p class=">

bg-primary text-white

"

Important background color.

p

<p class=">

bg-success text-white

"

Success background color.

p

<p class=">

bg-info text-white

"

Informational background color.

p

<p class=">

bg-warning text-white

"

Warning background color

p

<p class=">

bg-danger text-white

"

Danger background color.

p

<p class=">

bg-secondary text-white

"

Subheading background color.

p

<p class=">

bg-dark text-white

"

Black background color.

p

<p class=">

bg-light text-dark

"

Light gray background color.

p

div

Try it »