Bootstrap

What is the font-size Class in Bootstrap?

Bootstrap provides several different font-size classes, each of which corresponds to a different font size. The font-size class in Bootstrap is a set of pre-defined CSS styles that allow developers to easily change the font size of text elements. These classes can be applied to any HTML tag.

This write-up will explain the font-size classes in Bootstrap.

What is the font-size Class in Bootstrap?

In Bootstrap 5, the font-size classes are applied using the “fs-*”, where “*” indicates the font size value. The “fs-*” classes have the predefined CSS “font-size” property.

For a practical demonstration, analyze the example stated below.

Example

The below example shows the Bootstrap classes “fs-1” to “fs-6”. These classes make the element’s font size equal to the “<h1>”, “<h2>”, “<h3>”, “<h4>”, “<h5>”, and “<h6>” elements, respectively. So, add “<p>” elements and assign them the “fs-*” classes to apply font-size classes:

<p class="fs-1">Linuxhint</p>

<p class="fs-2">Linuxhint</p>

<p class="fs-3">Linuxhint</p>

<p class="fs-4">Linuxhint</p>

<p class="fs-5">Linuxhint</p>

<p class="fs-6">Linuxhint</p>

Output

You can also use CSS to add styles to the desired classes. For instance, the CSS “background” is added to each class. You can add CSS styles according to your preferences.

Style “fs-1” Class

.fs-1 {

background-color: #CDE990;

}

Style “fs-2” Class

.fs-2 {

background-color: #AAE3E2;

}

Style “fs-3” Class

.fs-3 {

background-color: #f5c080;

}

Style “fs-4” Class

.fs-4 {

background-color: #FEDEFF;

}

Style “fs-5” Class

.fs-5 {

background-color: #FAD3E7;

}

Style “fs-6” Class

.fs-6 {

background-color: #BFDB38;

}

Output

That was all about using the font-size classes using Bootstrap.

Conclusion

The “fs-*” classes in Bootstrap are utilized to apply font sizes to the elements, where the “*” symbol denotes the value from 1 to 6. First, add HTML elements to specify some text. Then, add the “fs-*” class to the particular element. These classes have the CSS “font-size” property with a specific value. This write-up has explained the Bootstrap font-size classes.

About the author

Nadia Bano

I am an enthusiastic and forward-looking software engineer with an aim to explore the global software industry. I love to write articles on advanced-level designing, coding, and testing.