Open In App

Bootstrap 5 Small tables

Last Updated : 24 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Bootstrap 5 Small tables are used to create the small size of tables. These tables are just smaller versions of the normal tables.

Bootstrap 5 Small tables Class:

  • table-sm: By using this class we can convert a normal table into a smaller table by cutting all cell padding in half.

Syntax:

<table class="table table-sm">
  ...
</table>

Example 1: Here we will create a small table that will not contain any caption or foot.

HTML




<!DOCTYPE html>
<html>
  
<head>
          rel="stylesheet" 
          integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" 
          crossorigin="anonymous">
</head>
  
<body class="m-3">
    <center>
        <h1 class="text-success">
            GeeksforGeeks
        </h1>
        <strong>Bootstrap 5 Tables Small Table</strong>
    </center>
    <table class="table table-sm">
        <thead>
            <tr>
                <th scope="col">No</th>
                <th scope="col">Course</th>
                <th scope="col">Price</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <th scope="row">1</th>
                <td>HTML- Basics</td>
                <td>$29</td>
            </tr>
            <tr>
                <th scope="row">2</th>
                <td>CSS- Basics</td>
                <td>$25</td>
            </tr>
            <tr>
                <th scope="row">3</th>
                <td>JS- Basics</td>
                <td>$35</td>
            </tr>
        </tbody>
    </table>
</body>
  
</html>


Output:

Bootstrap 5 Small tables

Bootstrap 5 Small tables

Example 2: In this example, we will attach the foot and caption as we did in our normal table, but with a small table.

HTML




<!DOCTYPE html>
<html>
  
<head>
         rel="stylesheet"
         integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
            crossorigin="anonymous">
</head>
  
<body class="m-3">
    <center>
        <h1 class="text-success">
            GeeksforGeeks
        </h1>
        <strong>Bootstrap 5 Tables Small Table</strong>
    </center>
    <table class="table caption-top table-sm">
        <caption>Front-end Courses</caption>
        <thead class="table-light">
            <tr>
                <th scope="col">No</th>
                <th scope="col">Course</th>
                <th scope="col">Price</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <th scope="row">1</th>
                <td>HTML- Basics</td>
                <td>$29</td>
            </tr>
            <tr>
                <th scope="row">2</th>
                <td>CSS- Basics</td>
                <td>$25</td>
            </tr>
            <tr>
                <th scope="row">3</th>
                <td>JS- Basics</td>
                <td>$35</td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <th scope="row"></th>
                <td>Front-End Bundle</td>
                <td>$89</td>
            </tr>
        </tfoot>
    </table>
</body>
  
</html>


Output: 

Bootstrap 5 Small tables

Bootstrap 5 Small tables

Reference: https://getbootstrap.com/docs/5.0/content/tables/#small-tables



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

Similar Reads