Bootstrap 5 Tutorial

v5.3.0

Bootstrap 5 Tutorial

Typography in Bootstrap 5

Typography: Bootstrap includes global typography settings, headings, body text, lists, and more.

Global Typography Settings

Bootstrap sets basic global display, typography, and link styles. These are applied to the <body> element.

Default Body Text

This is a paragraph of text. Bootstrap sets basic global display, typography, and link styles. When more control is needed, check out the textual utility classes.

You can use the mark tag to highlight text.

Default Settings:
  • Font family: system font stack
  • Base font size: 1rem (16px)
  • Line height: 1.5
  • Font weight: 400 (normal)
Applied to:
  • <body> element
  • All paragraphs <p>
  • List items <li>
  • Other text elements

Headings

All HTML Headings

h1. Bootstrap heading

h2. Bootstrap heading

h3. Bootstrap heading

h4. Bootstrap heading

h5. Bootstrap heading
h6. Bootstrap heading
HeadingExampleFont SizeFont WeightLine Height
<h1>Sample2.5rem (40px)5001.2
<h2>Sample2rem (32px)5001.2
<h3>Sample1.75rem (28px)5001.2
<h4>Sample1.5rem (24px)5001.2
<h5>Sample1.25rem (20px)5001.2
<h6>Sample1rem (16px)5001.2
Heading Classes

You can use heading classes to make other elements look like headings:

This paragraph looks like an h1

This paragraph looks like an h2

This paragraph looks like an h3

<!-- Using heading classes on other elements -->
            <p class="h1">h1. Bootstrap heading</p>
            <p class="h2">h2. Bootstrap heading</p>
            <p class="h3">h3. Bootstrap heading</p>

Customizing Headings

Small Secondary Text

Fancy display headingWith faded secondary text

<h3>
            Fancy display heading
            <small class="text-muted">With faded text</small>
            </h3>

Use the <small> tag or .small class for smaller, secondary text.

Display Headings

Display 1

Display 6

<h1 class="display-1">Display 1</h1>
            <h1 class="display-2">Display 2</h1>
            <!-- ... up to display-6 -->

Display headings are larger, lighter heading style for hero sections.

Inline Text Elements

Common Inline Styles

You can use the mark tag to highlight text.

This line of text is meant to be treated as deleted text.

This line of text is meant to be treated as no longer accurate.

This line of text is meant to be treated as an addition to the document.

This line of text will render as underlined.

This line of text is meant to be treated as fine print.

This line rendered as bold text.

This line rendered as italicized text.

ElementExamplePurpose
<mark>Highlighted textHighlight
<del>Deleted textDeleted/removed
<s>No longer accurateStrikethrough
<ins>Inserted textAdded content
<u>UnderlinedUnderline
<small>Small textFine print
<strong>BoldImportance
<em>ItalicEmphasis

Text Alignment

Alignment Classes

Left aligned text on all viewport sizes.

Center aligned text on all viewport sizes.

Right aligned text on all viewport sizes.

Responsive Alignment

This text is left aligned on mobile, center aligned on tablet, and right aligned on desktop.

ClassBreakpointAlignment
text-startAll screensLeft align
text-centerAll screensCenter align
text-endAll screensRight align
text-sm-centersm and upCenter on tablets+
text-md-endmd and upRight on desktop+
text-lg-startlg and upLeft on large screens+
<!-- Responsive text alignment -->
            <p class="text-start text-md-center text-lg-end">
            Aligns differently on different screens
            </p>

            <!-- Center text only on medium screens -->
            <p class="text-start text-md-center">
            Centered on tablet+
            </p>

Text Transformation

Lowercase

ALL LOWERCASE TEXT.

text-lowercase
Uppercase

all uppercase text.

text-uppercase
Capitalize

all words capitalized.

text-capitalize

Font Weight and Italics

Font Weight

Bold text.

Bolder weight text (relative to the parent element).

Semibold weight text.

Normal weight text.

Light weight text.

Lighter weight text (relative to the parent element).

Font Style

Italic text.

Text without font style.

Monospace

This is in monospace

ClassEffectCSS Equivalent
fw-boldBold textfont-weight: 700
fw-semiboldSemibold textfont-weight: 600
fw-normalNormal textfont-weight: 400
fw-lightLight textfont-weight: 300
fst-italicItalic textfont-style: italic
fst-normalNormal font stylefont-style: normal
font-monospaceMonospace fontfont-family: monospace

Text Colors

Contextual Text Colors
Primary
.text-primary
Secondary
.text-secondary
Success
.text-success
Danger
.text-danger
Warning
.text-warning
Info
.text-info
Light
.text-light bg-dark
Dark
.text-dark
Body
.text-body
Muted
.text-muted
White
.text-white bg-dark
Black 50%
.text-black-50
White 50%
.text-white-50 bg-dark
Note: Text color utilities are generated from the theme colors map, so they work with any color scheme you set up.

Text Decoration

Text Decoration

This text has a line underneath it.

This text has a line going through it.

This link has its text decoration removed

Text Wrap
This text should wrap.
This text should overflow the parent.
Word Break

mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm

Line Height

.lh-1
This is a long paragraph of text to show how the line-height affects the text. The line height is set to 1.

.lh-sm
This is a long paragraph of text to show how the line-height affects the text. The line height is set to sm.

.lh-base
This is a long paragraph of text to show how the line-height affects the text. The line height is set to base.

ClassLine HeightUse Case
lh-11Tight spacing
lh-sm1.25Small spacing
lh-base1.5Default (body text)
lh-lg2Large spacing
Typography Best Practices
  • ✅ Use proper heading hierarchy (h1 → h2 → h3)
  • ✅ Maintain sufficient contrast for readability
  • ✅ Use line-height of 1.5 for body text
  • ✅ Limit line length to 50-75 characters
  • ✅ Use responsive typography for different screens
  • ✅ Choose font sizes that create clear hierarchy