Open In App

Typography in Bootstrap

Last Updated : 05 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Typography is a feature of Bootstrap for styling and formatting text content. It is used to create customized headings, inline subheadings, lists, and paragraphs, aligning, adding more design-oriented font styles, and much more. Bootstrap supports global settings for the font stack, Headings and Link styles to be used in the web app for every type of OS and Device to deliver the best user interface.

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:

BootstrapTypography1

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">
            GeeksforGeeks //A Muted Text.
        </p>
        <p>GeeksforGeeks - Normal Paragraph</p>
        <!-- using lead class-->
        <p class="lead">
            GeeksforGeeks - Lead Paragraph
        </p>
        <!-- using mark-->
        <mark>GeeksforGeeks - Highlighted</mark>

        <br><br>

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

Output:

BootstrapTypography

Typography in Bootstrap Example Output

Supported Browser:



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads