07 Oct Bootstrap – Change the Text Background Color on a web page
Learn how to set the background color for text on a web page using the contextual classes in Bootstrap with live running examples. The following are the Contextual Classes to change the background color:
- .bg-primary: key information
- .bg-success: success action
- .bg-info: set information
- .bg-warning: set warning message
- .bg-danger: set danger message
- .bg-secondary: less important info
- .bg-dark: dark background color
- .bg-light: light background color
Example – Change the Text Background Color
Let us now see an example to change the background color for text in Bootstrap:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Background Color Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="container">
<h2>Text Background</h2>
<p class="bg-primary">This is example text</p>
<p class="bg-warning">This is example text</p>
<p class="bg-danger">This is example text</p>
<p class="bg-info">This is example text</p>
<p class="bg-secondary">This is example text</p>
<p class="bg-success">This is example text</p>
<p class="bg-dark text-white">This is example text</p>
<p class="bg-light">This is example text</p>
</div>
</body>
</html>
Output

Video Tutorial – Change Text Background Color
The following is the complete video tutorial to learn how to change the text background color in Bootstrap:
If you liked the tutorial, spread the word and share the link and our website Studyopedia with others:
Read More:
No Comments