how to give color to text in bootstrap?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

In this tutorial, we will learn how to give color to text in bootstrap.

To give color to text, put the .text-primary class to change the color of the text.

Table of contents

  • Includes bootstrap view
  • Includes bootstrap library
  • Define its class name

Step 1: Includes bootstrap view

To ensure proper rendering and touch zooming for all devices, add the responsive viewport meta tag to your <head>.

   <meta name="viewport" content="width=device-width, initial-scale=1">

Step 2: Includes bootstrap library

First of all, load the Bootstrap framework CSS into the head tag of your webpage.

<!-- Bootstrap CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
    </script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js">
    </script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js">
    </script>

Step 3: Define its class name

After that, create the text color.

    <div class="container">
        <h2>Bootstrap Colors List</h2>
        <ul>
            <li class="text-muted">aGuideHub</li>
            <li class="text-primary">aGuideHub</li>
            <li class="text-success">aGuideHub</li>
            <li class="text-info">aGuideHub</li>
            <li class="text-warning">aGuideHub</li>
            <li class="text-danger">aGuideHub</li>
            <li class="text-secondary">aGuideHub</li>
            <li class="text-white">aGuideHub</li>
            <li class="text-dark">aGuideHub</li>
            <li class="text-body">aGuideHub</li>
            <li class="text-light">aGuideHub</li>
        </ul>
    </div>

Example.

Let’s look at the following example to understand how it basically works:

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Bootstrap Color Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
    </script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js">
    </script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js">
    </script>
</head>

<body>
    <div class="container">
        <h2>Bootstrap Colors List</h2>
        <ul>
            <li class="text-muted">aGuideHub</li>
            <li class="text-primary">aGuideHub</li>
            <li class="text-success">aGuideHub</li>
            <li class="text-info">aGuideHub</li>
            <li class="text-warning">aGuideHub</li>
            <li class="text-danger">aGuideHub</li>
            <li class="text-secondary">aGuideHub</li>
            <li class="text-white">aGuideHub</li>
            <li class="text-dark">aGuideHub</li>
            <li class="text-body">aGuideHub</li>
            <li class="text-light">aGuideHub</li>
        </ul>
    </div>
</body>

</html>

Check the output of the above code example.

Bootstrap, Text, Color

All the best 👍