Bootstrap Tables - Bootstrap 5 Striped, Responsive Tables



Bootstrap Table

  • Here is the examples for choosing styling of tables with Bootstrap.
how-to-create-table-with-bootstrap

Sample Code

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>

<div class="container mt-3">           
  <table class="table">
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Abc</td>
        <td>Abc</td>
        <td>Kaashiv@gmail.com</td>
      </tr>
      <tr>
        <td>Abc</td>
        <td>Abc</td>
        <td>Wikitechy@gmail.com</td>
      </tr>
      <tr>
        <td>Abc</td>
        <td>Abc</td>
        <td>KaashivInfotech@gmail.com</td>
      </tr>
    </tbody>
  </table>
</div>
</body>
</html>

Output

bootstrap-tables

Bootstrap Table Variants

  • table-*: This class is used to color a table, its row, or a cell to bootstrap’s pre-defined color.

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <div class="bd-example">
        <table class="table">
          <thead>
            <tr>
              <th scope="col">Class</th>
              <th scope="col">Heading</th>
              <th scope="col">Heading</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <th scope="row">Default</th>
              <td>Cell</td>
              <td>Cell</td>
            </tr>
            
              <tr class="table-primary">
                <th scope="row">Primary</th>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
              <tr class="table-secondary">
                <th scope="row">Secondary</th>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
              <tr class="table-success">
                <th scope="row">Success</th>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
              <tr class="table-danger">
                <th scope="row">Danger</th>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
              <tr class="table-warning">
                <th scope="row">Warning</th>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
              <tr class="table-info">
                <th scope="row">Info</th>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
              <tr class="table-light">
                <th scope="row">Light</th>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
              <tr class="table-dark">
                <th scope="row">Dark</th>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
          </tbody>
        </table>
      </div>
  </body>
</html>

Output

bootstrap-table-variant

Bootstrap Table Striped Rows Example 1

  • Use .table-striped to add zebra-striping to any table row within the <tbody>.

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <div class="bd-example">
        <table class="table table-striped">
            <thead>
          <tr>
            <th scope="col">#</th>
            <th scope="col">First</th>
            <th scope="col">Last</th>
            <th scope="col">Handle</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">1</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Kaashiv@gmail.com</td>
          </tr>
          <tr>
            <th scope="row">2</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Wikitechy@gmail.com</td>
          </tr>
          <tr>
            <th scope="row">3</th>
            <td colspan="2">Larry the Bird</td>
            <td>KaashivInfotech@gmail.com</td>
          </tr>
        </tbody>
        </table>
      </div>
  </body>
</html>

Output

bootstrap-table-striped

Bootstrap Table Striped Rows Example 2

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <div class="bd-example">
        <table class="table table-dark table-striped">
            <thead>
          <tr>
            <th scope="col">#</th>
            <th scope="col">First</th>
            <th scope="col">Last</th>
            <th scope="col">Handle</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">1</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Kaashiv@gmail.com</td>
          </tr>
          <tr>
            <th scope="row">2</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Wikitechy@gmi.com</td>
          </tr>
          <tr>
            <th scope="row">3</th>
            <td colspan="2">Larry the Bird</td>
            <td>KaashivInfotech@gmil.com</td>
          </tr>
        </tbody>
        </table>
      </div>
  </body>
</html>

Output

bootstrap-table-striped-rows

Bootstrap Table Striped Rows Example 3

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <div class="bd-example">
        <table class="table table-success table-striped">
            <thead>
          <tr>
            <th scope="col">#</th>
            <th scope="col">First</th>
            <th scope="col">Last</th>
            <th scope="col">Handle</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">1</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Kaashiv@gmil.com</td>
          </tr>
          <tr>
            <th scope="row">2</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Wikitechy@gmil.com</td>
          </tr>
          <tr>
            <th scope="row">3</th>
            <td colspan="2">Larry the Bird</td>
            <td>KaashivInfotech@gmil.com</td>
          </tr>
        </tbody>
        </table>
      </div>
  </body>
</html>

Output

bootstrap-table-striped-row

Bootstrap Striped columns Example 1

  • Use .table-striped-columns to add zebra-striping to any table column within the <tbody>.

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <div class="bd-example">
        <table class="table table-striped-columns">
            <thead>
          <tr>
            <th scope="col">#</th>
            <th scope="col">First</th>
            <th scope="col">Last</th>
            <th scope="col">Handle</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">1</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Kaashiv@gmail.com</td>
          </tr>
          <tr>
            <th scope="row">2</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Wikitechy@gmil.com</td>
          </tr>
          <tr>
            <th scope="row">3</th>
            <td colspan="2">Larry the Bird</td>
            <td>KaashivInfotech@gmail.com</td>
          </tr>
        </tbody>
        </table>
      </div>
  </body>
</html>

Output

bootstrap-table-striped-columns

Bootstrap Table Striped columns Example 2

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <div class="bd-example">
        <table class="table table-dark table-striped-columns">
            <thead>
          <tr>
            <th scope="col">#</th>
            <th scope="col">First</th>
            <th scope="col">Last</th>
            <th scope="col">Handle</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">1</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Kaashiv@gmil.com</td>
          </tr>
          <tr>
            <th scope="row">2</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Wikitechy@gmil.com</td>
          </tr>
          <tr>
            <th scope="row">3</th>
            <td colspan="2">Larry the Bird</td>
            <td>KaashivInfotech@gmil.com</td>
          </tr>
        </tbody>
        </table>
      </div>
  </body>
</html>

Output

bootstrap-table-striped-column

Bootstrap Table Striped columns Example 3

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <div class="bd-example">
        <table class="table table-success table-striped-columns">
            <thead>
          <tr>
            <th scope="col">#</th>
            <th scope="col">First</th>
            <th scope="col">Last</th>
            <th scope="col">Handle</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">1</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Kaashiv@gmil.com</td>
          </tr>
          <tr>
            <th scope="row">2</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Wikitechy@gmil.com</td>
          </tr>
          <tr>
            <th scope="row">3</th>
            <td colspan="2">Larry the Bird</td>
            <td>KaashivInfotech@gmi.com</td>
          </tr>
        </tbody>
        </table>
      </div>
  </body>
</html>

Output

table-striped-columns-bootstrap

Bootstrap Table Hoverable rows Example 1

  • Add .table-hover to enable a hover state on table rows within a <tbody>.

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <div class="bd-example">
      <table class="table table-hover">
          <thead>
        <tr>
          <th scope="col">#</th>
          <th scope="col">First</th>
          <th scope="col">Last</th>
          <th scope="col">Handle</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th scope="row">1</th>
          <td>Abc</td>
          <td>Abc</td>
          <td>Kaashiv@gmil.com</td>
        </tr>
        <tr>
          <th scope="row">2</th>
          <td>Abc</td>
          <td>Abc</td>
          <td>Wikitechy@gmil.com</td>
        </tr>
        <tr>
          <th scope="row">3</th>
          <td colspan="2">Larry the Bird</td>
          <td>KaashivInfotech@gmil.com</td>
        </tr>
      </tbody>
      </table>
    </div>
  </body>
</html>

Output

bootstrap-table-hover

Bootstrap Table Hoverable rows Example 2

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <div class="bd-example">
        <table class="table table-dark table-hover">
            <thead>
          <tr>
            <th scope="col">#</th>
            <th scope="col">First</th>
            <th scope="col">Last</th>
            <th scope="col">Handle</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">1</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Kaashiv@gmil.com</td>
          </tr>
          <tr>
            <th scope="row">2</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Wikitechy@gmil.com</td>
          </tr>
          <tr>
            <th scope="row">3</th>
            <td colspan="2">Larry the Bird</td>
            <td>KaashivInfotech@gmil.com</td>
          </tr>
        </tbody>
        </table>
      </div>
  </body>
</html>

Output

bootstrap-table-hover-color

Bootstrap Table Hoverable rows Example 3

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <!doctype html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
        <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
        <title>Bootstrap Example</title>
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
      </head>
      <body class="p-3 m-0 border-0 bd-example">
        <div class="bd-example">
            <table class="table table-striped table-hover">
                <thead>
              <tr>
                <th scope="col">#</th>
                <th scope="col">First</th>
                <th scope="col">Last</th>
                <th scope="col">Handle</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <th scope="row">1</th>
                <td>Abc</td>
                <td>Abc</td>
                <td>Kaashiv@gmail.com</td>
              </tr>
              <tr>
                <th scope="row">2</th>
                <td>Abc</td>
                <td>Abc</td>
                <td>Wikitechy@gmail.com</td>
              </tr>
              <tr>
                <th scope="row">3</th>
                <td colspan="2">Larry the Bird</td>
                <td>KaashivInfotech@gmail.com</td>
              </tr>
            </tbody>
            </table>
          </div>
      </body>
    </html>    
  </body>
</html>

Output

bootstrap-table-hover-row

Bootstrap Active Tables

  • Highlight a table row or cell by adding a .table-active class.

Sample Code

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
    <div class="bd-example">
        <table class="table">
          <thead>
            <tr>
              <th scope="col">#</th>
              <th scope="col">First</th>
              <th scope="col">Last</th>
              <th scope="col">Handle</th>
            </tr>
          </thead>
          <tbody>
            <tr class="table-active">
              <th scope="row">1</th>
              <td>Abc</td>
              <td>Abc</td>
              <td>Kaashiv@gmail.com</td>
            </tr>
            <tr>
              <th scope="row">2</th>
              <td>Abc</td>
              <td>Abc</td>
              <td>Wikitechy@gmail.com</td>
            </tr>
            <tr>
              <th scope="row">3</th>
              <td colspan="2" class="table-active">Larry the Bird</td>
              <td>KaashivInfotech@gmail.com</td>
            </tr>
          </tbody>
        </table>
      </div> 
</body>
</html>

Output

bootstrap-table-active

Bootstrap Bordered Tables

  • Add .table-bordered for borders on all sides of the table and cells.

Sample Code

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
    <div class="bd-example">
        <table class="table table-bordered border-primary">
            <thead>
          <tr>
            <th scope="col">#</th>
            <th scope="col">First</th>
            <th scope="col">Last</th>
            <th scope="col">Handle</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">1</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Kaashiv@gmil.com</td>
          </tr>
          <tr>
            <th scope="row">2</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Wikitechy@gmail.com</td>
          </tr>
          <tr>
            <th scope="row">3</th>
            <td colspan="2">Larry the Bird</td>
            <td>KaashivInfotech@gmail.com</td>
          </tr>
        </tbody>
      </div>
</body>
</html>

Output

bootstrap-border-table

Bootstrap Tables without Borders

  • Bootstrap provides a simple way to create tables without borders. You can achieve this effect by adding the "table-borderless" class to your table.

Sample Code

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
  <div class="bd-example">
    <table class="table table-borderless">
        <thead>
      <tr>
        <th scope="col">#</th>
        <th scope="col">First</th>
        <th scope="col">Last</th>
        <th scope="col">Handle</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">1</th>
        <td>Abc</td>
        <td>Abc</td>
        <td>Kaashiv@gmail.com</td>
      </tr>
      <tr>
        <th scope="row">2</th>
        <td>Abc</td>
        <td>Abc</td>
        <td>Wikitechy@gmail.com</td>
      </tr>
      <tr>
        <th scope="row">3</th>
        <td colspan="2">Larry the Bird</td>
        <td>KaashivInfotech@gmail.com</td>
      </tr>
    </tbody>
  </div>
</body>
</html>

Output

bootstrap-table-without-border

Bootstrap Small tables

  • Add .table-sm to make tables more compact by cutting cell padding in half.

Sample Code

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
  <div class="table table-sm">
    <table class="table table-borderless">
        <thead>
      <tr>
        <th scope="col">#</th>
        <th scope="col">First</th>
        <th scope="col">Last</th>
        <th scope="col">Handle</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">1</th>
        <td>Abc</td>
        <td>Abc</td>
        <td>Kaashiv@gmail.com</td>
      </tr>
      <tr>
        <th scope="row">2</th>
        <td>Abc</td>
        <td>Abc</td>
        <td>Wikitechy@gmail.com</td>
      </tr>
      <tr>
        <th scope="row">3</th>
        <td colspan="2">Larry the Bird</td>
        <td>KaashivInfotech@gmail.com</td>
      </tr>
    </tbody>
    </table>
  </div>
</body>
</html>

Output

bootstrap-table-small

Bootstrap Table Group Dividers

  • A thicker border, darker between table groups— <thead>, <tbody>, and <tfoot>—with .table-group-divider. Customize the color by changing the border-top-color.

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <table class="table">
      <thead>
        <tr>
          <th scope="col">#</th>
          <th scope="col">First</th>
          <th scope="col">Last</th>
          <th scope="col">Handle</th>
        </tr>
      </thead>
      <tbody class="table-group-divider">
        <tr>
          <th scope="row">1</th>
          <td>Abc</td>
          <td>Abc</td>
          <td>Kaashiv@gmail.com</td>
        </tr>
        <tr>
          <th scope="row">2</th>
          <td>Abc</td>
          <td>Abc</td>
          <td>Wikitechy@gmail.com</td>
        </tr>
        <tr>
          <th scope="row">3</th>
          <td colspan="2">Larry the Bird</td>
          <td>KaashivInfotech@gmail.com</td>
        </tr>
      </tbody>
    </table>
  </body>
</html>

Output

bootstrap-table-group-divider

Bootstrap Table Vertical alignment

  • Table cells of <thead> are always vertical aligned to the bottom.
  • Table cells in <tbody> inherit their alignment from <table> and are aligned to the top by default.

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <div class="bd-example">
        <div class="table-responsive">
          <table class="table align-middle">
            <thead>
              <tr>
                <th scope="col" class="w-25">Heading 1</th>
                <th scope="col" class="w-25">Heading 2</th>
                <th scope="col" class="w-25">Heading 3</th>
                <th scope="col" class="w-25">Heading 4</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>This cell inherits <code>vertical-align: middle;</code> from the table</td>
                <td>This cell inherits <code>vertical-align: middle;</code> from the table</td>
                <td>This cell inherits <code>vertical-align: middle;</code> from the table</td>
                <td>This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.</td>
              </tr>
              <tr class="align-bottom">
                <td>This cell inherits <code>vertical-align: bottom;</code> from the table row</td>
                <td>This cell inherits <code>vertical-align: bottom;</code> from the table row</td>
                <td>This cell inherits <code>vertical-align: bottom;</code> from the table row</td>
                <td>This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.</td>
              </tr>
              <tr>
                <td>This cell inherits <code>vertical-align: middle;</code> from the table</td>
                <td>This cell inherits <code>vertical-align: middle;</code> from the table</td>
                <td class="align-top">This cell is aligned to the top.</td>
                <td>This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.</td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
  </body>
</html>

Output

bootstrap-table-vertical-align

Bootstrap Table Nesting

  • Bootstrap provides a way to create nested tables, which can be useful when you want to display hierarchical data or when you need to present related data in a structured way.
  • To create a nested table in Bootstrap, you can use the same HTML structure as for a regular table, but place one table within another.

Sample Code

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
    <div class="table table-striped">
        <table class="table table-striped table-bordered">
          <thead>
            <tr>
              <th scope="col">#</th>
              <th scope="col">First</th>
              <th scope="col">Last</th>
              <th scope="col">Handle</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <th scope="row">1</th>
              <td>Mark</td>
              <td>Otto</td>
              <td>@mdo</td>
            </tr>
            <tr>
              <td colspan="4">
                <table class="table mb-0">
                  <thead>
                    <tr>
                      <th scope="col">Header</th>
                      <th scope="col">Header</th>
                      <th scope="col">Header</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <th scope="row">A</th>
                      <td>First</td>
                      <td>Last</td>
                    </tr>
                    <tr>
                      <th scope="row">B</th>
                      <td>First</td>
                      <td>Last</td>
                    </tr>
                    <tr>
                      <th scope="row">C</th>
                      <td>First</td>
                      <td>Last</td>
                    </tr>
                  </tbody>
                </table>
              </td>
            </tr>
            <tr>
              <th scope="row">3</th>
              <td>Larry</td>
              <td>the Bird</td>
              <td>@twitter</td>
            </tr>
          </tbody>
        </table>
        </div>
</body>
</html>

Output

bootstrap-nested-table

Bootstrap Table head Example 1

  • To create a table head in Bootstrap, you can use the <thead> element. Inside the <thead> element, you can define the table header row using the <tr> element, and then specify the header cells using the <th> element.

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <div class="bd-example">
        <table class="table">
          <thead class="table-light">
            <tr>
              <th scope="col">#</th>
              <th scope="col">First</th>
              <th scope="col">Last</th>
              <th scope="col">Handle</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <th scope="row">1</th>
              <td>Abc</td>
              <td>Abc</td>
              <td>Kaashiv@gmail.com</td>
            </tr>
            <tr>
              <th scope="row">2</th>
              <td>Abc</td>
              <td>Abc</td>
              <td>Wikitechy@gmail.com</td>
            </tr>
            <tr>
              <th scope="row">3</th>
              <td>Abc</td>
              <td>Abc</td>
              <td>KaashivInfotech@gmail.com</td>
            </tr>
          </tbody>
        </table>
        </div>
  </body>
</html>

Output

bootstrap-table-head

Bootstrap Table head Example 2

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <table class="table">
        <thead class="table-dark">
          <tr>
            <th scope="col">#</th>
            <th scope="col">First</th>
            <th scope="col">Last</th>
            <th scope="col">Handle</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">1</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Kaashiv@gmail.com</td>
          </tr>
          <tr>
            <th scope="row">2</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Wikitechy@gmail.com</td>
          </tr>
          <tr>
            <th scope="row">3</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>KaashivInfotech@gmail.com</td>
          </tr>
        </tbody>
      </table>
      </div>
  </body>
</html>

Output

bootstrap-table-header

Bootstrap Table Foot

  • In Bootstrap, a table footer can be created using the <tfoot> element. The table footer is used to display summary information or other types of data related to the table.

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <table class="table">
        <thead class="table-light">
          <tr>
            <th scope="col">#</th>
            <th scope="col">First</th>
            <th scope="col">Last</th>
            <th scope="col">Handle</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">1</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>KaashivInfotech@gmail.com</td>
          </tr>
          <tr>
            <th scope="row">2</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Kaashiv@gmail.com</td>
          </tr>
          <tr>
            <th scope="row">3</th>
            <td>Abc</td>
            <td>Abc</td>
            <td>Wikitechy@gmail.com</td>
          </tr>
        </tbody>
        <tfoot>
          <tr>
            <td>Footer</td>
            <td>Footer</td>
            <td>Footer</td>
            <td>Footer</td>
          </tr>
        </tfoot>
      </table>
      </div>
  </body>
</html>

Output

bootstrap-table-footer

Bootstrap Table Captions

  • A <caption> functions like a heading for a table. It helps users with screen readers to find a table and understand what it’s about and decide if they want to read it.

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <!doctype html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
        <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
        <title>Bootstrap Example</title>
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
      </head>
      <body class="p-3 m-0 border-0 bd-example">
        <div class="bd-example">
            <table class="table">
              <caption>List of users</caption>
                <thead>
                  <tr>
                    <th scope="col">#</th>
                    <th scope="col">First</th>
                    <th scope="col">Last</th>
                    <th scope="col">Handle</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <th scope="row">1</th>
                    <td>Abc</td>
                    <td>Abc</td>
                    <td>Kaashiv@gmail.com</td>
                  </tr>
                  <tr>
                    <th scope="row">2</th>
                    <td>Abc</td>
                    <td>Abc</td>
                    <td>Wikitechy@gmail.com</td>
                  </tr>
                  <tr>
                    <th scope="row">3</th>
                    <td colspan="2">Larry the Bird</td>
                    <td>KaashivInfotech@gmail.com</td>
                  </tr>
                </tbody>
            </table>
          </div>
  </body>
</html>

Output

bootstrap-table-caption

Bootstrap Table Always responsive

  • Across every breakpoint, use .table-responsive for horizontally scrolling tables.

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
  </head>
  <body class="p-3 m-0 border-0 bd-example">
    <div class="table-responsive">
        <div class="table-responsive">
          <table class="table">
            <thead>
              <tr>
                <th scope="col">#</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <th scope="row">1</th>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
              <tr>
                <th scope="row">2</th>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
              <tr>
                <th scope="row">3</th>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
  </body>
</html>

Output

bootstrap-table-responsive

Bootstrap Table Breakpoint specific

  • Use .table-responsive{-sm|-md|-lg|-xl} as needed to create responsive tables up to a particular breakpoint. From that breakpoint and up, the table will behave normally and not scroll horizontally.

Sample Code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.2/assets/css/docs.css" rel="stylesheet">
    <title>Bootstrap Example</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
  </head>
  <body class="table-responsive-md">
    <div class="bd-example">
        <div class="table-responsive-md">
          <table class="table">
            <thead>
              <tr>
                <th scope="col">#</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
                <th scope="col">Heading</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <th scope="row">1</th>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
              <tr>
                <th scope="row">2</th>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
              <tr>
                <th scope="row">3</th>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
                <td>Cell</td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>      
  </body>
</html>

Output

bootstrap-table-breakpoint

Related Searches to Bootstrap Tables - Bootstrap 5 Striped, Responsive Tables