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 …
Section overview
5 resourcesExplores 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
- Create a webpage with a blue background and white text.
- Create a webpage with different sections, each with a different background color.
- 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.
Related topics
Keep learning with adjacent tracks.
Popular tools
Helpful utilities for quick tasks.
Random Password Generator
Create secure, complex passwords with custom length and character options.
Use toolLatest articles
Fresh insights from the CodiWiki team.
AI in Drug Discovery: Accelerating Medical Breakthroughs
In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…
Read articleAI in Retail: Personalized Shopping and Inventory Management
In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …
Read articleAI 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 articleAI 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 articleAI in Legal Compliance: Ensuring Regulatory Adherence
In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…
Read article