Open In App

Bootstrap 5 Text Font Size

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

Bootstrap 5 Text font size is used to set the text font size. We all know that we have 6 different header tags, and depending on that we have 6 classes to set the font size. Heading class applies font-size, font-weight and line-height properties.

Text Font size classes:

ClassDescription
fs-1Set text size equal to the h1 tag
fs-2Set text size equal to the h2 tag
fs-3Set text size equal to the h3 tag
fs-4Set text size equal to the h4 tag
fs-5Set text size equal to the h5 tag
fs-6Set text size equal to the h6 tag

Syntax:

<tag class="fs-1">...</tag>

Examples of Bootstrap 5 Text Font Size

The below example illustrates the Bootstrap 5 Text Font size:

Example 1: In this example, we will use three sizes fs-1, fs-3, and fs-5.

HTML
<!DOCTYPE html>
<html>
    <head>
        <link
            href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
            rel="stylesheet"
            integrity=
"sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
            crossorigin="anonymous"
        />
    </head>

    <body>
        <div class="container">
            <!-- Bootstrap Font Size classes used -->
            <u>Font size: fs-1</u>
            <p class="fs-1">
                A Computer Science Portal for
                Geeks
            </p>

            <u>Font size: fs-3</u>
            <p class="fs-3">
                A Computer Science Portal for
                Geeks
            </p>

            <u>Font size: fs-5</u>
            <p class="fs-5">
                A Computer Science Portal for
                Geeks
            </p>
        </div>
    </body>
</html>

Output:

FontSizeBootstrap

Bootstrap 5 Text Font Size Example Output


Example 2: In this example, we will use three sizes fs-2, fs-4, and fs-6.

HTML
<!DOCTYPE html>
<html>
    <head>
        <link
            href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
            rel="stylesheet"
            integrity=
"sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
            crossorigin="anonymous"
        />
    </head>

    <body>
        <div class="container">

            <!-- Bootstrap Font Size classes used -->
            <u>Font size: fs-2</u>
            <p class="fs-2">
                A Computer Science Portal for
                Geeks
            </p>
            <u>Font size: fs-4</u>
            <p class="fs-4">
                A Computer Science Portal for
                Geeks
            </p>
            <u>Font size: fs-6</u>
            <p class="fs-6">
                A Computer Science Portal for
                Geeks
            </p>
        </div>
    </body>
</html>

Output:

FoontSize

Bootstrap 5 Text Font Size Example Output



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads