Bootstrap TablesWe can create different types of Bootstrap tables by using different classes to style them. Bootstrap Basic Table:The basic Bootstrap table has a light padding and only horizontal dividers. The .table class is used to add basic styling to a table. Example: Test it NowBootstrap Striped Rows Table:The .table-striped class is used to add zebra-stripes to a table: Test it NowBootstrap Bordered table:The .table-bordered class is used to add borders on all sides of the table and cells: Test it NowBootstrap Hover rows Table:The .table-hover class is used to enable a hover state on table rows: Test it NowBootstrap Condensed table:The .table-condensed class is used to make a table more compact by cutting cell padding in half: Test it NowBootstrap Contextual classes:.Contextual classes are used to color table rows (<tr>) or table cells (<td>): Following are the different contextual classes:
Example: Test it NowResponsive tables:The .table-responsive class is used to create a responsive table. You can open the responsible table even on small devices (under 768px). Then the table will be scrolled horizontally. Displays larger than 768px wide, there is no difference. See this example: Test it NowSome newly added tables in Bootstrap 4:Black/Dark TableThe .table-dark class is used to add a black background to the table: ExampleTest it NowDark Striped TableCombine the .table-dark class and .table-striped class to create a dark, striped table: ExampleTest it NowHoverable Dark TableThe .table-hover class is used to add a hover effect (grey background color) on table rows: ExampleTest it NowBootstrap 4 Contextual TableContextual classes can be used to color the whole table (<table>), the table rows (<tr>) or table cells (<td>). The classes that can be used are: .table-primary, .table-success, .table-info, .table-warning, .table-danger, .table-active, .table-secondary, .table-light and .table-dark: Let's take an example to see the usage of all contextual classes in a Bootstrap 4 table. ExampleTest it NowTable Head ColorsYou can change the background color of the table header by using .thead-dark class to add a black background to table headers, and the .thead-light class to add a grey background to table headers. Example:Test it NowSmall TableThe .table-sm class is used to make the table smaller by cutting cell padding in half. Example:Test it NowNext TopicBootstrap Form |