Bootstrap / Bootstrap Typography and Colors

Working with Bootstrap Colors and Backgrounds

In this tutorial, we will explore Bootstrap's color and background utilities. You'll learn how to use these utilities to enhance the visual appeal of your webpages, and to create …

Tutorial 3 of 5 5 resources in this section

Section overview

5 resources

Explores Bootstrap’s typography system and color utilities to enhance visual appearance.

Introduction

This tutorial is designed to help you understand and effectively use Bootstrap's color and background utilities. By the end of this tutorial, you will be able to choose appropriate colors for your webpages, apply background colors, and create a consistent color scheme throughout your website using Bootstrap.

Prerequisites:
- Basic knowledge of HTML and CSS.
- Familiarity with Bootstrap framework.

Step-by-Step Guide

Bootstrap offers a wide range of color and background classes which can be used to change the text color, background color, link color, etc. It includes color classes for typography, background, borders, and other components.

Bootstrap Color Classes

Bootstrap includes classes for setting text and link colors. The classes .text-{color} and .text-{context} can be used to set the color of text, where {color} can be any of Bootstrap’s color names (like danger, success, dark, etc.) and {context} is for contextual classes (like primary, secondary, info, etc.)

Bootstrap Background Classes

Bootstrap also includes background color classes. The .bg-{color} and .bg-{context} classes are used to set the background color of an element, where {color} can be any of Bootstrap's color names and {context} is for contextual classes.

Code Examples

Changing Text Color

Here's how you can change the color of text in Bootstrap:

<!-- This will make the text color red -->
<p class="text-danger">This is a danger paragraph.</p>

<!-- This will make the text color green -->
<p class="text-success">This is a success paragraph.</p>

Changing Background Color

Here's how you can change the background color of an element in Bootstrap:

<!-- This will make the background color red -->
<div class="bg-danger">This is a danger div.</div>

<!-- This will make the background color green -->
<div class="bg-success">This is a success div.</div>

Summary

Congratulations, you've learned how to work with color and background utilities in Bootstrap! You can now use these utilities to enhance the look of your webpages and create a consistent color scheme across your website.

Next, you might want to dive deeper into Bootstrap and learn about its other components, like buttons, forms, and navbars.

Practice Exercises

  1. Create a webpage with a blue background and white text.
  2. Create a webpage with different sections, each with a different background color.
  3. Create a webpage with different paragraphs, each with a different text color.

Solutions:
1.

<div class="bg-primary text-white">This is a webpage with a blue background and white text.</div>
<div class="bg-primary">This is the first section with a blue background.</div>
<div class="bg-danger">This is the second section with a red background.</div>
<div class="bg-success">This is the third section with a green background.</div>
<p class="text-primary">This is a paragraph with blue text.</p>
<p class="text-danger">This is a paragraph with red text.</p>
<p class="text-success">This is a paragraph with green text.</p>

Need Help Implementing This?

We build custom systems, plugins, and scalable infrastructure.

Discuss Your Project

Related topics

Keep learning with adjacent tracks.

View category

HTML

Learn the fundamental building blocks of the web using HTML.

Explore

CSS

Master CSS to style and format web pages effectively.

Explore

JavaScript

Learn JavaScript to add interactivity and dynamic behavior to web pages.

Explore

Python

Explore Python for web development, data analysis, and automation.

Explore

SQL

Learn SQL to manage and query relational databases.

Explore

PHP

Master PHP to build dynamic and secure web applications.

Explore

Popular tools

Helpful utilities for quick tasks.

Browse tools

Backlink Checker

Analyze and validate backlinks.

Use tool

URL Encoder/Decoder

Encode or decode URLs easily for web applications.

Use tool

MD5/SHA Hash Generator

Generate MD5, SHA-1, SHA-256, or SHA-512 hashes.

Use tool

JavaScript Minifier & Beautifier

Minify or beautify JavaScript code.

Use tool

Word to PDF Converter

Easily convert Word documents to PDFs.

Use tool

Latest articles

Fresh insights from the CodiWiki team.

Visit blog

AI in Drug Discovery: Accelerating Medical Breakthroughs

In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…

Read article

AI in Retail: Personalized Shopping and Inventory Management

In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …

Read article

AI in Public Safety: Predictive Policing and Crime Prevention

In the realm of public safety, the integration of Artificial Intelligence (AI) stands as a beacon of innovati…

Read article

AI in Mental Health: Assisting with Therapy and Diagnostics

In the realm of mental health, the integration of Artificial Intelligence (AI) stands as a beacon of hope and…

Read article

AI in Legal Compliance: Ensuring Regulatory Adherence

In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…

Read article

Need help implementing this?

Get senior engineering support to ship it cleanly and on time.

Get Implementation Help