Typography in Bootstrap

Bootstrap Typography provides a standardized and flexible approach to text styling, offering various classes for headings, paragraphs, and inline text elements. It ensures consistent typography across different devices and screen sizes, enhancing readability and aesthetics.

Typography can be used to create: 

  • Headings
  • Subheadings
  • Text and Paragraph font color, font type, and alignment
  • Lists
  • Other inline elements

Some classes and Tags to implement the typography feature of bootstrap: 

Inline ElementDescription
h1 – h6Font styling resembling a heading, without using the associated HTML element
text-mutedFades the text, making it appear greyed out
displayEnhances headings for better visual presentation
leadMakes a paragraph stand out visually
markHighlights the text
smallCreates secondary subheadings
initialismRenders abbreviations in slightly smaller text size
blockquoteIndicates quoted content
blockquote-footerProvides footer details for identifying the source of the quote
text-centerAligns text to the center
list-inlineMakes list items appear inline
text-truncateShortens longer text by truncating with an ellipsis
text-uppercaseTransforms text to uppercase
text-lowercaseTransforms text to lowercase
text-capitalizeTransforms text to capitalize the first letter of each word, leaving other letters in lowercase
pre-scrollableMakes a preformatted element scrollable
dl-horizontalAligns term and description elements side-by-side
list-unstyledRemoves default list-style and left margin from list items
text-rightAligns text to the right
text-leftAligns text to the left

Example 1: In this example we use Bootstrap classes to style headings and display properties. It includes headings from h1 to h3 with corresponding classes, along with display classes (display-3, display-4, and display-5) for different styles.

HTML
<!DOCTYPE html>
<html>
    <head>
        <link
            rel="stylesheet"
            href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
            integrity=
"sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"
            crossorigin="anonymous"
        />
        <title>Text-muted</title>
    </head>
    <body>
        <p class="h1">h1. Bootstrap heading</p>

        <p class="h2">h2. Bootstrap heading</p>

        <p class="h3">h3. Bootstrap heading</p>

        <h3 class="display-3">
            Display-3 property
        </h3>
        <h3 class="display-4">
            Display-4 property
        </h3>
        <h3 class="display-5">
            Display-5 property
        </h3>
    </body>
</html>

Output:

Bootstrap typographt heading and display property Example Output

Example 2: In this example we demonstrates Bootstrap typography features. It includes examples of muted text, lead paragraph, highlighted text using the mark element, blockquote with footer, and an abbreviation with initialism class.

HTML
<!DOCTYPE html>
<html>
    <head>
        <link
            rel="stylesheet"
            href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
            integrity=
"sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"
            crossorigin="anonymous"
        />
        <title>Bootstrap Typography</title>
    </head>
    <body>
        <!-- Muted text-->
        <p class="text-muted">
            w3wiki //A Muted Text.
        </p>
        <p>w3wiki - Normal Paragraph</p>
        <!-- using lead class-->
        <p class="lead">
            w3wiki - Lead Paragraph
        </p>
        <!-- using mark-->
        <mark>w3wiki - Highlighted</mark>

        <br><br>

        <!-- using blockquote tag and blockquote-footer class.-->
        <blockquote>w3wiki</blockquote>
        <blockquote class="blockquote-footer">
            a CS portal
        </blockquote>
        <!-- using initialism class-->
        <abbr
            title="w3wiki"
            class="text-success initialism"
        >
            GfG</abbr
        >
        is a CS portal
    </body>
</html>

Output:

Typography in Bootstrap Example Output

Supported Browser: