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