Bootstrap Components

Bootstrap Table

Overview

Tables are presented in most applications (web, desktop or mobile application) and they are a key element in presenting data to the end user.

Today, with the importance that the user interface has, knowing how to enhance the appearance of a table becomes as relevant as it is. In this scenario, one of the technologies that has become reference is Bootstrap. This front-end framework, among many other features, provides a number of features for styling and optimizing the display of various components, such as table.

Main table in Bootstrap

To style a table with Bootstrap, simply add the table class to the <table> tag, and some visual formatting will already be applied, as displayed on the screenshot .

Bootstrap basic table
<table class="table">
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">1</th>
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
      <th scope="row">2</th>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
      <th scope="row">3</th>
      <td>Larry</td>
      <td>the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>

Inverse tables.

Among the latest tables in Bootsrap 4 is the inverse tables. Class .table-inverse can easily change the coloration of the table.

Bootstrap inverse table
<table class="table table-inverse">
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">1</th>
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
      <th scope="row">2</th>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
      <th scope="row">3</th>
      <td>Larry</td>
      <td>the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>

Additional classes

There are also some classes that allow you to apply a different styles to a table, they are::

<table class="table-striped"> Toggles the color of table rows

<table class="table-bordered"> Adds border to the table;

<table class="table-hover"> Activates the highlight of a line when we hover the mouse cursor over it;

<table class="table-condensed"> Reduces the height of table rows, making it more compact.

To apply these styles, simply add the desired classes to the <table>: <table class="table table-striped table-bordered table-condensed table-hover">

Table head opportunities

Much like default and inverse tables, run one of two modifier classes to make <thead> appear dark or light gray.

Bootstrap table head options
<table class="table">
  <thead class="thead-inverse">
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">1</th>
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
      <th scope="row">2</th>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
      <th scope="row">3</th>
      <td>Larry</td>
      <td>the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>

<table class="table">
  <thead class="thead-default">
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">1</th>
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
      <th scope="row">2</th>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
      <th scope="row">3</th>
      <td>Larry</td>
      <td>the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>

Striped rows

Zebra-like stripes may be incorporated with the .table-striped class, an example

Bootstrap striped rows
<table class="table table-striped">
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">1</th>
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
      <th scope="row">2</th>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
      <th scope="row">3</th>
      <td>Larry</td>
      <td>the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>

Hover Rows

To make a hover side effect in the rows of your table add in the .table-hover class:

Bootstrap hover rows
<table class="table table-hover">
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">1</th>
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
      <th scope="row">2</th>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
      <th scope="row">3</th>
      <td colspan="2">Larry the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>

Bordered Table

You can surely bring in the borders on the every single table slide and a cell with the .table-bordered class:

Bootstrap bordered table
<table class="table table-bordered">
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">1</th>
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
      <th scope="row">2</th>
      <td>Mark</td>
      <td>Otto</td>
      <td>@TwBootstrap</td>
    </tr>
    <tr>
      <th scope="row">3</th>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
      <th scope="row">4</th>
      <td colspan="2">Larry the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>

Condensed Table

If you wish to make your table more compact - you can easily cut cell padding in half with this class: .table-condensed.

Take note that, while Bootstrap 4 uses .table-sm to condense a table, Bootstrap 3 uses .table-condensed. Each cut cell padding in half.

Bootstrap condensed table
<table class="table table-sm">
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">1</th>
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
      <th scope="row">2</th>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
      <th scope="row">3</th>
      <td colspan="2">Larry the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>

Contextual Classes

Use the contextual classes to color a table cells (<td>) and table rows (<tr>):

Bootstrap contextual classes
<!-- On rows -->
<tr class="table-active">...</tr>
<tr class="table-success">...</tr>
<tr class="table-warning">...</tr>
<tr class="table-danger">...</tr>
<tr class="table-info">...</tr>

<!-- On cells (`td` or `th`) -->
<tr>
  <td class="table-active">...</td>
  <td class="table-success">...</td>
  <td class="table-warning">...</td>
  <td class="table-danger">...</td>
  <td class="table-info">...</td>
</tr>

Changing the rows of a table Bootstrap 3 does not use the .table- prefix for its contextual classes. Bootstrap 3 uses .active while Bootstrap 4 uses .table-active. Other than that, both of these versions use the exact same 5 contextual keywords (active, success, info, warning, danger). Listed here you can see the information about each of the possible types:

● active: Applies the focus color to the table row or table cell

● success: Indicates a successful or positive action

● info: Indicates a neutral information change or action

● warning: Indicates a warning that you may need attention

● danger: Indicates a dangerous or potentially negative action

Responsive Tables

To create a responsive table - use the .table-responsive class. Table rolls in the horizontal way on gadgets that less than 768px. If the gadget is larger sized than 768px wide, then you will see no difference :

Bootstrap responsive tables

Bootstrap 4 allows you to add the .table-responsive class to the actual <table> element. Bootstrap 3 tables required that you add that class to a parent <div> element.

Examine a number of online video short training relating to Bootstrap tables

Connected topics:

Bootstrap tables: official documentation

Bootstrap tables  main documentation

W3schools:Bootstrap table tutorial

Bootstrap table  article

Bootstrap Tables Lecture

Bootstrap Tables Lecture

Best Free AI Website Generator

Generate AI websites with a simple prompt! Type in any language, export code in zip.


ChatGPT Website Generator



Best Free Website Builder Software

Create awesome websites offline! No coding. 9900+ templates. Edit and save locally, upload wherever.


Free website builder download for Win, Mac, Linux!



Best Website Templates

HTML Business Templates

HTML Business Templates

Web Design HTML Templates

Web Design HTML Templates

HTML eCommerce Website Template

HTML eCommerce Website Template

Hotel HTML Template

Hotel HTML Template

Landing Page HTML Template

Landing Page HTML Template

Premium Design HTML Themes

Premium Design HTML Themes

HTML Resume Template

HTML Resume Template

Online Shopping HTML Template

Online Shopping HTML Template

HTML Responsive Templates

HTML Responsive Templates

Latest Posts

  1. Launch a Site in No Time? We Reviewed 24 AI Builders to Determine the Clear Winner.
  2. List of 20 AI Code Builders and Generators - Get your code built by AI.
  3. 15 Best AI Website Creators and Generators - Generate your website instantly with AI.
  4. AI website creator and generator - how to create a website with AI in just 2 minutes.
  5. Best Free AI website generator and builder - create a website design with AI.
  6. Best Website Builder AIBest Free AI Website Builder - Create Website Design with AI
  7. Best Website Builder for Consultants, Magazines, Churches, Authors
  8. Best Website Builder for Designers, Videos, Education, Software Companies
  9. Website Builder for Beginners, Bloggers, Writers, IT Companies
  10. Best Website Builder for Restaurants, Online Stores, Real Estate, Musicians
  11. Best Website Builder for podcasts and affiliate marketing
  12. Therapists and nonprofits Website Builder
  13. Portfolio and SEO Website Builder
  14. Website Builder for Kids and Musicians
  15. Website Builder for Photographers and Artists
  16. HTML Code Generator - HTML Code Creator
  17. Web Design Program - Website Design Tool
  18. Landing Page Generator - Landing Page Builder
  19. No Coding Website Builder - Website Builder For Small Business
  20. Innovative HTML Builder Drag And Drop Free for Your Next Project
  21. Is There A Completely Free QR Code Generator
  22. Extremely Comfortable Business Website Constructor Review
  23. Bootstrap Select
  24. Bootstrap Panel
  25. Bootstrap Tabs
  26. Bootstrap Toggle
  27. Bootstrap Modal Popup
  28. Bootstrap Row
  29. Bootstrap Multiselect
  30. Bootstrap Media queries
  31. Bootstrap Login Forms
  32. Bootstrap Layout
  33. Bootstrap Jumbotron
  34. Bootstrap Button Group
  35. Bootstrap Breakpoints
  36. Bootstrap Navbar
  37. Bootstrap Tooltip
  38. Bootstrap Textarea
  39. Bootstrap Switch
  40. Bootstrap Slider
  41. Bootstrap Progress Bar
  42. Bootstrap Label
  43. Bootstrap Header
  44. Bootstrap Clearfix
  45. Bootstrap Sidebar
  46. Bootstrap Radio
  47. Bootstrap Offset
  48. Bootstrap Menu
  49. Bootstrap Columns
  50. Bootstrap Checkbox
  51. Bootstrap Accordion
  52. Bootstrap Image
  53. Bootstrap Grid
  54. Bootstrap Form
  55. Bootstrap Glyphicons
  56. Bootstrap List
  57. Bootstrap Carousel
  58. Bootstrap Icons
  59. Bootstrap Collapse
  60. Bootstrap Popover
  61. Bootstrap Input
  62. Bootstrap Modal
  63. Bootstrap Pagination
  64. Bootstrap Button
  65. Bootstrap Alert