Skip to content
Tutorials Center
My learning

Topics

Lesson 12 of 58 ยท Content

Typography

Style text with Bootstrap 5.3: heading classes, display-*, lead, small, mark, blockquotes, abbreviations, unstyled and inline lists, plus fs-* and fw-* utilities.

Most of a website is text, so typography is where Bootstrap does its quietest and most valuable work. Out of the box, headings get sensible sizes and spacing, paragraphs get a comfortable line height, and the font is the system font of each visitor's device, so text loads instantly and looks native everywhere.

This lesson shows what you get for free and the classes you can add: heading classes, the large display-* headings, the lead paragraph, small and highlighted text, blockquotes, abbreviations, list helpers, and the fs-* and fw-* utilities for size and weight. It assumes you already have a page from Your First Bootstrap Page.

Headings

Elements <h1> to <h6> are styled by Bootstrap's reboot: each gets a size, a bold-ish weight, a tight line height and a small bottom margin. On narrower screens the larger headings shrink automatically (Bootstrap uses responsive font sizes), so a big title never overflows a phone.

Sometimes the meaning of a heading differs from its size. A page should have one <h1>, and the next level down should be <h2>, but you may want a small heading in a sidebar or a big-looking <h2>. The classes .h1 to .h6 give any element the look of a heading level without changing the HTML structure:

Heading elements and heading classes

Pick the element for the document outline (see HTML headings) and the class for the appearance. Screen readers and search engines use the element; people looking at the page use the size.

Display headings

Ordinary headings are modest. For a hero section or landing page title you want something much bigger. The classes display-1 to display-6 produce large, light-weight headings, with display-1 the biggest:

Display headings

Use the classes on the heading element that fits your outline, normally an <h1>, as above. Like normal headings they scale down on small screens. If you want a different weight, combine them with a weight utility such as fw-bold.

Lead paragraphs

A lead paragraph is an intro that stands out: slightly larger and lighter than normal body text. It is perfect for the sentence under a title.

HTML
<h1 class="display-5">Weekend Notebook</h1>
<p class="lead">Short trips, light bags and good coffee.</p>

Inline text: small, mark and friends

Bootstrap restyles the standard inline elements and offers class versions for use on other elements:

Element Class version Look
<small> .small smaller text (about 87.5% of its parent)
<mark> .mark highlighted text with a yellow background
<del> strikethrough, for removed text
<s> strikethrough, for text no longer accurate
<ins> underlined, for added text
<u> underlined text
<strong> bold
<em> italic

Choose by meaning: <mark> for text that is relevant right now (a search match), <del> and <ins> for edits, <s> for a crossed-out old price. These elements are explained in Text Formatting.

Inline text elements

text-muted is deprecated. Older tutorials use text-muted for gray secondary text. Since Bootstrap 5.3 the class is deprecated in favor of text-body-secondary, which also adapts to dark mode. You will learn the color classes in Colors and Backgrounds.

Blockquotes

For a quotation from another source, add the class blockquote to a <blockquote> element. To credit the source, wrap everything in a <figure> and add a <figcaption class="blockquote-footer">. A <cite> element names the work.

A blockquote with a source

Alignment utilities such as text-center and text-end on the <figure> move the whole block; they are explained in the next lesson, Text Utilities.

Abbreviations

The <abbr> element marks an abbreviation, and its title attribute shows the long form in a tooltip. Bootstrap underlines it with a dotted line so people know there is more to see. Add .initialism for an all-caps abbreviation at a slightly smaller size:

HTML
<p>Bootstrap is built on <abbr title="Cascading Style Sheets">CSS</abbr>.</p>
<p>The <abbr title="HyperText Markup Language" class="initialism">HTML</abbr> spec is a living standard.</p>

Because the tooltip depends on hovering, never put essential information only in a title. Spell the full term out the first time you use it in the text.

Lists

Lists are styled by the browser by default. Bootstrap adds two helpers for the two most common changes.

list-unstyled removes bullets and left padding from a direct list (nested lists keep their bullets unless you add the class to them too). It is the starting point for menus and link lists.

list-inline with list-inline-item on each <li> puts items on one line with a small gap, ideal for footers and tag lists.

Unstyled and inline lists

For a description list, the grid can lay terms and descriptions side by side: put the class row on the <dl>, col-sm-3 on each <dt> and col-sm-9 on each <dd>. More list styling lives in List Groups, Breadcrumbs and Pagination.

Font size and weight utilities

You do not need to write CSS to change the size or weight of a single piece of text.

  • fs-1 to fs-6 set the font size to match heading levels; fs-1 is the largest. Unlike .h1 to .h6, they carry no margin or line-height changes, only the size.
  • Weight: fw-bold, fw-bolder, fw-semibold, fw-medium, fw-normal, fw-light and fw-lighter. (bolder and lighter are relative to the parent.)
  • Style: fst-italic and fst-normal.
  • Line height: lh-1, lh-sm, lh-base, lh-lg, covered in the next lesson.
Size, weight and style utilities

The mb-1 and mb-3 classes set a bottom margin; they belong to the spacing utilities. Utility classes can be combined freely, and each one does exactly one thing, which makes the markup readable once you know the names.

flowchart TD
  A["Need different text styling?"] --> B{"Is it a heading?"}
  B -->|"Yes, size only"| C["h1-h6 or display-1 to display-6 class"]
  B -->|"No"| D{"One property?"}
  D -->|"Size"| E["fs-1 to fs-6"]
  D -->|"Weight or style"| F["fw-* or fst-*"]
  D -->|"Meaning"| G["small, mark, del, abbr, blockquote"]

A quick way to choose between classes and elements.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. You need an h2 for the document outline, but it should look like a small heading. What do you write?

    The element keeps the correct outline, and the class .h5 changes only the appearance.
  2. 2. Which classes create very large, light-weight hero headings?

    display-1 is the largest. The fs-* classes only set font size, and lead is for intro paragraphs.
  3. 3. How do you put list items on one line?

    list-inline removes bullets and list-inline-item lays items out inline with a small gap.
  4. 4. Which markup credits the source of a quotation properly?

    This is Bootstrap's pattern: figure, blockquote.blockquote and figcaption.blockquote-footer.
  5. 5. Which class replaces the deprecated text-muted in Bootstrap 5.3?

    text-body-secondary gives the same quieter gray look and adapts to color modes.

Summary

  • Reboot styles h1 to h6 and body text for you; classes .h1 to .h6 give any element a heading's look.
  • display-1 to display-6 make large hero headings, and lead marks an introductory paragraph.
  • Use the right element for meaning: small, mark, del, ins, s, abbr, blockquote inside a figure.
  • list-unstyled removes list bullets; list-inline plus list-inline-item lays items on a line.
  • fs-*, fw-* and fst-* change size, weight and style without custom CSS, and combine freely.

Next lesson: Text Utilities.