tutorialstonight logo


Bootstrap provide some classes that are color specific classes, which are used to specifically change color of either text, background-color, link-style or hover color.

These contextual classes are used to deliever certain meaning through the color of contents.

We will see color classes for 3 different use :

  1. Text Colors
  2. Anchor Color and Hover Effect
  3. Background Color

1.) Bootstrap Text Color

Text color classes are used to set colors of text in bootstrap. Following are the color classes for text in bootstrap with their color value.

Class Name Color Value Of Text
.text-primary #007bff
.text-secondary #6c757d
.text-success #28a745
.text-warning #ffc107
.text-danger #dc3545
.text-info #17a2b8
.text-light #f8f9fa
.text-dark #343a40
.text-muted #6c757d
.text-white #fff

Bootstrap Anchor Color

The same above clsses that we used above also works fine for anchor tags (<a>). In addition to text of color it also provide hover color and focus color to anchor tags.

Note: .text-muted and .text-white has no link style.

Class Name Link Text Color hover and focus color
.text-primary #007bff #0062cc
.text-secondary #6c757d #545b62
.text-success #28a745 #1e7e34
.text-warning #ffc107 #d39e00
.text-danger #dc3545 #bd2130
.text-info #17a2b8 #117a8b
.text-light #f8f9fa #dae0e5
.text-dark #343a40 #1d2124

Bootstrap Background Colors

Same as text color you can also set background color of HTML elements using bootstrap. Bootstrap class for background color are shown below.

You can also set text color for text to be visible with such background.

Note: You can also set .bg-* classes to anchor tag. On anchor tags you will get hover effect for elements background.










Anchor tag Primary Color Anchor tag Warning Color Anchor tag Danger Color

points to remember Points to remember:
  1. Bootstrap color classes is used to give certain color to HTML elements which defines some information regarding the content.
  2. You can set text color, background color, anchor color with hover and focus effect on it.
Bootstrap 4 Table