Bootstrap Text/Typography
14 April 2025 | Category: Bootstrap
Bootstrap Tutorial: Style Text with Typography
In this Bootstrap tutorial, you’ll learn how to use Bootstrap’s typography classes to style text, such as headings, paragraphs, and lists. Bootstrap makes it easy to create consistent, responsive text styles for your webpage.
What You’ll Learn
- Using Bootstrap heading classes
- Styling paragraphs and text
- Applying text alignment and transformations
- Creating styled lists
Prerequisites
- Basic knowledge of HTML
- A text editor (e.g., VS Code, Notepad)
- A web browser (e.g., Chrome, Firefox)
Step 1: Understand Bootstrap Typography
Bootstrap provides classes to style text, like headings (h1
to h6
), paragraphs, and more, with responsive sizes and spacing. It also includes utilities for alignment, weight, and decoration.
Assume Bootstrap CSS is included in your project (we’ll skip the <link>
tag as requested).
Step 2: Style Headings
Bootstrap enhances default headings and offers classes like h1
through h6
for consistent styling. You can also use display headings for larger text. Try this code:
<div class="container">
<h1>Main Heading</h1>
<h2>Subheading</h2>
<h3 class="display-4">Big Display Text</h3>
<h4 class="h1">Small Tag, Big Style</h4>
</div>
Explanation:
container
: Centers and constrains content.h1
,h2
: Standard heading tags with Bootstrap’s polished styles.display-4
: Makes text larger and bolder for emphasis.h1
(onh4
): Appliesh1
styling to a smaller tag.
This creates a variety of heading sizes, all responsive.
Step 3: Style Paragraphs
Bootstrap offers classes for paragraph formatting, like lead text or muted styles. Add this below the headings:
<div class="container">
<p class="lead">This is a prominent paragraph that stands out.</p>
<p class="text-muted">This text is softer and less prominent.</p>
<p class="fw-bold">This paragraph is bold.</p>
</div>
Explanation:
lead
: Makes the paragraph larger and more noticeable.text-muted
: Applies a faded, secondary color.fw-bold
: Sets the text to bold weight.
These classes enhance readability and hierarchy.
Step 4: Align and Transform Text
You can align or transform text with utility classes. Try this:
<div class="container">
<p class="text-center">Centered text.</p>
<p class="text-end">Right-aligned text.</p>
<p class="text-uppercase">Uppercase text.</p>
<p class="text-capitalize">capitalized text.</p>
</div>
Explanation:
text-center
,text-end
: Aligns text to the center or right.text-uppercase
: Converts text to all uppercase.text-capitalize
: Capitalizes the first letter of each word.
These utilities give you quick control over text appearance.
Step 5: Style Lists
Bootstrap makes lists look clean and modern. Here’s an example with an unstyled list:
<div class="container">
<ul class="list-unstyled">
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
</div>
Explanation:
list-unstyled
: Removes default bullets and margins for a plain list.
You can also use list-inline
for horizontal lists (not shown here for brevity).
Final Code
Here’s a combined example with typography styles:
<div class="container">
<h1 class="display-3">Welcome</h1>
<h2 class="h4">Smaller subtitle</h2>
<p class="lead">This is the main introduction to our page.</p>
<p class="text-muted fw-bold">A subtle but bold note.</p>
<p class="text-center text-uppercase">Centered and uppercase.</p>
<ul class="list-unstyled">
<li>Feature one</li>
<li>Feature two</li>
<li>Feature three</li>
</ul>
</div>
Output
Your webpage should show:
- A large “Welcome” display heading.
- A smaller subtitle styled like
h4
. - A prominent lead paragraph and a bold, muted one.
- Centered, uppercase text.
- A clean, unstyled list without bullets.
All text adjusts for readability across screen sizes.
Next Steps
- Explore the Bootstrap Typography Docs for more classes.
- Try
text-primary
ortext-success
for colored text. - Combine with Bootstrap’s grid for complex layouts.
Conclusion
You’ve learned how to style text with Bootstrap’s typography classes! With just a few classes, you can create professional, responsive text designs. Keep experimenting to enhance your webpages.