Bootstrap Typography
Learn how Bootstrap provides useful classes for headings, paragraphs, text alignment and text styling.
What is Typography?
Typography refers to the way text is displayed and organized on a webpage.
Bootstrap provides several predefined classes that help developers create clean and readable text without writing custom CSS for every element.
Typography controls how headings, paragraphs, text size, alignment and other text elements look on a webpage.
Bootstrap Headings
Bootstrap provides styling for standard HTML
heading elements from <h1>
to <h6>.
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Output:
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Display Headings
Bootstrap provides .display-1 through
.display-6 classes for creating
large and attractive headings.
<h1 class="display-1">
Display Heading
</h1>
Example:
Bootstrap Training
CIIT Training Institute
Lead Paragraph
The .lead class is used to make a
paragraph more prominent than a normal paragraph.
<p class="lead">
Learn Full Stack Development with practical training.
</p>
Output:
Learn Full Stack Development with practical training.
Text Alignment
Bootstrap provides classes to align text to the left, center or right.
<p class="text-start">
Left Aligned Text
</p>
<p class="text-center">
Center Aligned Text
</p>
<p class="text-end">
Right Aligned Text
</p>
Output:
Left Aligned Text
Center Aligned Text
Right Aligned Text
Text Transform
Bootstrap provides classes to change the capitalization of text.
<p class="text-uppercase">
bootstrap training
</p>
<p class="text-lowercase">
BOOTSTRAP TRAINING
</p>
<p class="text-capitalize">
bootstrap training institute
</p>
Output:
bootstrap training
BOOTSTRAP TRAINING
bootstrap training institute
Font Weight
Bootstrap provides utility classes to control the font weight of text.
<p class="fw-light">
Light Text
</p>
<p class="fw-normal">
Normal Text
</p>
<p class="fw-bold">
Bold Text
</p>
<p class="fw-bolder">
Bolder Text
</p>
Output:
Light Text
Normal Text
Bold Text
Bolder Text
Font Style
Bootstrap also provides classes for italic and normal font styles.
<p class="fst-italic">
Italic Text
</p>
<p class="fst-normal">
Normal Text
</p>
Italic Text
Normal Text
Text Colors
Bootstrap provides utility classes for applying different colors to text.
<p class="text-primary">
Primary Text
</p>
<p class="text-success">
Success Text
</p>
<p class="text-danger">
Danger Text
</p>
<p class="text-warning">
Warning Text
</p>
<p class="text-muted">
Muted Text
</p>
Output:
Primary Text
Success Text
Danger Text
Warning Text
Muted Text
Text Decoration
Bootstrap provides utility classes for controlling text decoration.
<p class="text-decoration-underline">
Underlined Text
</p>
<p class="text-decoration-line-through">
Deleted Text
</p>
<p class="text-decoration-none">
No Decoration
</p>
Underlined Text
Deleted Text
No Decoration
Text Wrapping
Bootstrap provides utility classes that help control how text behaves inside a container.
<div class="text-wrap">
This text can wrap inside the container.
</div>
<div class="text-nowrap">
This text will remain on one line.
</div>
Text Truncation
The .text-truncate class can be used
to shorten overflowing text with an ellipsis.
<div class="text-truncate"
style="max-width: 300px;">
This is a very long text that will be truncated.
</div>
Output:
Text Spacing and Paragraphs
Bootstrap spacing utilities can be used to create proper spacing between text elements.
<p class="mb-3">
First paragraph
</p>
<p class="mb-0">
Last paragraph
</p>
Bootstrap makes it easy to organize text with spacing utilities.
This paragraph has no bottom margin.
Real-Life Example – CIIT Training Institute
Suppose CIIT Training Institute wants to create a course introduction section.
<h1 class="fw-bold">
CIIT Training Institute
</h1>
<p class="lead">
Full Stack Development Training
</p>
<p class="text-muted">
Learn practical technologies with live projects.
</p>
Output:
CIIT Training Institute
Full Stack Development Training
Learn practical technologies with live projects.
Important Typography Classes
| Class | Purpose |
|---|---|
.display-1 to
.display-6
|
Large display headings |
.lead
|
Highlights a paragraph |
.text-start
|
Aligns text to the start |
.text-center
|
Centers text |
.text-end
|
Aligns text to the end |
.text-uppercase
|
Converts text to uppercase |
.text-lowercase
|
Converts text to lowercase |
.text-capitalize
|
Capitalizes words |
.fw-bold
|
Makes text bold |
.fst-italic
|
Makes text italic |
Common Mistakes
- Using too many different font styles on the same page.
- Using heading tags only for visual size instead of proper document structure.
- Using custom CSS when Bootstrap utility classes are already available.
- Ignoring readability while styling text.
Summary
In this lesson, we learned how Bootstrap typography utilities help us style and organize text on webpages.
We learned about headings, display headings, lead paragraphs, text alignment, text transformation, font weight, font style and text colors.
We also learned how Bootstrap typography classes can be combined to create clean, readable and professional webpage content.