Bootstrap 5 Typography
Bootstrap resets the browser's text defaults to something cleaner: a native system font stack, a base size of 1rem (16px), a line height of 1.5 and consistent margins on headings and paragraphs. On top of that it adds classes for bigger headings, lead paragraphs, inline text styles and more.
Headings
<h1> to <h6> get Bootstrap's sizes automatically. If you need the look of a heading without changing the document structure, use .h1 … .h6 on any element.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<h1>h1 heading</h1>
<h3>h3 heading <small class="text-body-secondary">with muted secondary text</small></h3>
<p class="h5">A paragraph styled like an h5</p>
<h6>h6 heading</h6>
</body>
</html>Display headings and lead
Display headings are larger and lighter, for hero sections. .lead makes a paragraph stand out as an introduction.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<p class="display-1 mb-0">Display 1</p>
<p class="display-4">Display 4</p>
<p class="display-6">Display 6</p>
<p class="lead">A lead paragraph is slightly larger and lighter than normal text.</p>
<p>A normal paragraph for comparison.</p>
</body>
</html>| Class | Effect |
|---|---|
.h1 … .h6 |
Heading size on any element |
.display-1 … .display-6 |
Extra-large, light headings (1 is biggest) |
.lead |
Larger intro paragraph |
.small / <small> |
0.875em text |
.mark / <mark> |
Highlighted text |
.initialism |
Smaller uppercase text for abbreviations |
Inline text elements
Bootstrap styles the semantic HTML elements so they look consistent:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<p>You can <mark>highlight</mark> text, show <del>deleted</del> and <ins>inserted</ins> text,
<s>strike it out</s>, <u>underline it</u>, or make it <small>small</small>.</p>
<p><abbr title="Cascading Style Sheets" class="initialism">CSS</abbr> abbreviations get a dotted underline.</p>
<p>Press <kbd>Ctrl</kbd> + <kbd>S</kbd> to save. Inline code: <code><div class="row"></code></p>
<figure>
<blockquote class="blockquote">
<p>Simplicity is prerequisite for reliability.</p>
</blockquote>
<figcaption class="blockquote-footer">Edsger W. Dijkstra</figcaption>
</figure>
</body>
</html>Text utilities
Most day-to-day typography is done with utility classes:
| Class | Effect |
|---|---|
.text-start / .text-center / .text-end |
Alignment (also responsive: .text-md-center) |
.text-uppercase / .text-lowercase / .text-capitalize |
Case transform |
.fw-bold / .fw-semibold / .fw-normal / .fw-light |
Font weight |
.fst-italic / .fst-normal |
Font style |
.fs-1 … .fs-6 |
Font size (same scale as headings) |
.lh-1 / .lh-sm / .lh-base / .lh-lg |
Line height |
.text-truncate |
One line with an ellipsis (needs a block with a width) |
.text-decoration-none / .text-decoration-underline |
Underline control |
.font-monospace |
Monospace font |
Lists
.list-unstyled removes bullets and indentation; .list-inline with .list-inline-item puts items side by side.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<ul class="list-unstyled">
<li>✔ No bullets</li>
<li>✔ No left padding</li>
</ul>
<ul class="list-inline">
<li class="list-inline-item">Home</li>
<li class="list-inline-item">·</li>
<li class="list-inline-item">About</li>
</ul>
<p class="text-center text-uppercase fw-bold fs-5">centred, uppercase, bold</p>
<div class="text-truncate border p-1" style="width: 220px;">This sentence is far too long to fit inside the box.</div>
</body>
</html>Tip: Use the right element for the meaning (
h2for a section title) and a class for the look (.h4if you want it smaller). Screen readers and search engines rely on the real heading levels.
Test yourself
Which class makes a paragraph look like an <h3> without changing its element?
- .heading-3
- .h3
- .display-3
- .fs-heading
What is .lead used for?
- Making text bold
- Making an intro paragraph stand out
- Adding a left border
- Creating links
Which class removes the bullets and padding from a list?
- .list-inline
- .list-none
- .list-unstyled
- .no-bullets