Table of Contents
Bootstrap Background Color: Customizing Backgrounds
Only Important Code
<div class="container"> <h2 id="article-heading-2">Contextual Backgrounds</h2> <p>Use the contextual background classes to provide "meaning through colors".</p> <p>Note that you can also add a .text-* class if you want a different text color:</p> <p class="bg-primary text-white">This text is important.</p> <p class="bg-success text-white">This text indicates success.</p> <p class="bg-info text-white">This text represents some information.</p> <p class="bg-warning text-white">This text represents a warning.</p> <p class="bg-danger text-white">This text represents danger.</p> <p class="bg-secondary text-white">Secondary background color.</p> <p class="bg-dark text-white">Dark grey background color.</p> <p class="bg-light text-dark">Light grey background color.</p> </div>
Full Code For The Above Example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap 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.1.0/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.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2 id="article-heading-4">Contextual Backgrounds</h2>
<p>Use the contextual background classes to provide "meaning through colors".</p>
<p>Note that you can also add a .text-* class if you want a different text color:</p>
<p class="bg-primary text-white">This text is important.</p>
<p class="bg-success text-white">This text indicates success.</p>
<p class="bg-info text-white">This text represents some information.</p>
<p class="bg-warning text-white">This text represents a warning.</p>
<p class="bg-danger text-white">This text represents danger.</p>
<p class="bg-secondary text-white">Secondary background color.</p>
<p class="bg-dark text-white">Dark grey background color.</p>
<p class="bg-light text-dark">Light grey background color.</p>
</div>
</body>
</html>
Only Important Code
<div class="container"> <h1 class="bg-primary text-white">h1 Bootstrap heading 1)</h1> <h2 class="bg-success text-white" id="article-heading-6">h2 Bootstrap heading 2</h2> <h3 class="bg-info text-white" id="article-heading-7">h3 Bootstrap heading 3</h3> <h4 class="bg-warning text-white">h4 Bootstrap heading 4</h4> <h5 class="bg-danger text-white">h5 Bootstrap heading 5</h5> <h6 class="bg-secondary text-white">h6 Bootstrap heading 6</h6> </div>
Full Code For The Above Example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap 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.1.0/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.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1 class="bg-primary text-white">h1 Bootstrap heading 1)</h1>
<h2 class="bg-success text-white" id="article-heading-9">h2 Bootstrap heading 2</h2>
<h3 class="bg-info text-white" id="article-heading-10">h3 Bootstrap heading 3</h3>
<h4 class="bg-warning text-white">h4 Bootstrap heading 4</h4>
<h5 class="bg-danger text-white">h5 Bootstrap heading 5</h5>
<h6 class="bg-secondary text-white">h6 Bootstrap heading 6</h6>
</div>
</body>
</html>