Open In App

Bootstrap 5 Utilities

Bootstrap 5 provides a lot of utilities to make a stylish, mobile-friendly, and responsive front-end website without using any CSS code. The utility layout is used for showing, hiding, aligning, and spacing content.

Bootstrap 5 utilities for layout:



Example 1: Let us see an example.




<!DOCTYPE html>
<html>
 
<head>
    <!-- Bootstrap CDN -->
    <link rel="stylesheet"
        href=
        crossorigin="anonymous">  
</head>
 
<body class="m-2">
    <h1 class="text-success"> GeeksforGeeks </h1>
    <h3>Bootstrap5 Layout Utilities</h3>
    <br>
    <section class="d-inline p-2 bg-primary text-white">
        GFG inline element
    </section>
    <br>
    <br>
    <section class="d-block p-2 bg-dark text-white">
        GFG block element
    </section>
</body>
</html>

Output:



 

Example 2: Let us see an example of display utility.




<!DOCTYPE html>
<html>
 
<head>
    <!-- Bootstrap CDN -->
    <link rel="stylesheet"
        href=
        crossorigin="anonymous">
</head>
 
<body class="m-2">
    <h1 class="text-success"> GeeksforGeeks </h1>
    <h3>Bootstrap5 Layout Utilities</h3>
    <br>
       <p><b>normal form of rows</b></p>
    <section>
        <div class="p-2 border">GFG 1</div>
        <div class="p-2 border">GFG 2</div>
        <div class="p-2 border">GFG 3</div>
     </section>
     <br>
     <p><b>When we applied display property in rows</b></p>
    <section class="d-flex ">
        <div class="p-2 border">GFG 1</div>
        <div class="p-2 border">GFG 2</div>
        <div class="p-2 border">GFG 3</div>
    </section>   
</body>
</html>

Output:

 

Reference: https://getbootstrap.com/docs/5.0/layout/utilities/


Article Tags :