2014-07-11 22:34:47 -07:00
---
2015-08-14 22:45:55 -07:00
layout: docs
2014-07-11 22:34:47 -07:00
title: Tables
2017-11-15 09:12:38 +00:00
description: Documentation and examples for opt-in styling of tables (given their prevalent use in JavaScript plugins) with Bootstrap.
2015-08-09 23:38:16 -07:00
group: content
2017-05-27 22:16:44 -07:00
toc: true
2014-07-11 22:34:47 -07:00
---
2016-05-08 14:15:34 -07:00
## Examples
2017-05-27 22:16:44 -07:00
Due to the widespread use of tables across third-party widgets like calendars and date pickers, we've designed our tables to be **opt-in** . Just add the base class `.table` to any `<table>` , then extend with custom styles or our various included modifier classes.
2016-10-02 18:27:53 -07:00
Using the most basic table markup, here's how `.table` -based tables look in Bootstrap. **All table styles are inherited in Bootstrap 4** , meaning any nested tables will be styled in the same manner as the parent.
2014-07-11 22:34:47 -07:00
2018-03-14 16:44:38 +01:00
{% capture example %}
2014-07-11 22:34:47 -07:00
< table class = "table" >
< thead >
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2014-07-11 22:34:47 -07:00
< / tr >
< / thead >
< tbody >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 1< / th >
2014-07-11 22:34:47 -07:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo </ td >
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 2< / th >
2014-07-11 22:34:47 -07:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat </ td >
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 3< / th >
2014-07-11 22:34:47 -07:00
< td > Larry< / td >
< td > the Bird< / td >
< td > @twitter </ td >
< / tr >
< / tbody >
< / table >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2014-07-11 22:34:47 -07:00
2017-08-18 18:23:06 -07:00
You can also invert the colors—with light text on dark backgrounds—with `.table-dark` .
2014-07-14 00:23:46 -07:00
2018-03-14 16:44:38 +01:00
{% capture example %}
2017-08-18 18:23:06 -07:00
< table class = "table table-dark" >
2014-07-14 00:23:46 -07:00
< thead >
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2014-07-14 00:23:46 -07:00
< / tr >
< / thead >
< tbody >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 1< / th >
2014-07-14 00:23:46 -07:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo </ td >
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 2< / th >
2014-07-14 00:23:46 -07:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat </ td >
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 3< / th >
2014-07-14 00:23:46 -07:00
< td > Larry< / td >
< td > the Bird< / td >
< td > @twitter </ td >
< / tr >
< / tbody >
< / table >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2014-07-14 00:23:46 -07:00
2014-07-13 23:45:34 -07:00
## Table head options
2017-08-18 18:23:06 -07:00
Similar to tables and dark tables, use the modifier classes `.thead-light` or `.thead-dark` to make `<thead>` s appear light or dark gray.
2014-07-13 23:45:34 -07:00
2018-03-14 16:44:38 +01:00
{% capture example %}
2014-07-13 23:45:34 -07:00
< table class = "table" >
2017-08-18 18:23:06 -07:00
< thead class = "thead-dark" >
2014-07-13 23:45:34 -07:00
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2014-07-13 23:45:34 -07:00
< / tr >
< / thead >
< tbody >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 1< / th >
2014-07-13 23:45:34 -07:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo </ td >
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 2< / th >
2014-07-13 23:45:34 -07:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat </ td >
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 3< / th >
2014-07-13 23:45:34 -07:00
< td > Larry< / td >
< td > the Bird< / td >
< td > @twitter </ td >
< / tr >
< / tbody >
2015-05-27 15:49:55 -07:00
< / table >
< table class = "table" >
2017-08-18 18:23:06 -07:00
< thead class = "thead-light" >
2014-07-13 23:45:34 -07:00
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2014-07-13 23:45:34 -07:00
< / tr >
< / thead >
< tbody >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 1< / th >
2014-07-13 23:45:34 -07:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo </ td >
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 2< / th >
2014-07-13 23:45:34 -07:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat </ td >
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 3< / th >
2014-07-13 23:45:34 -07:00
< td > Larry< / td >
< td > the Bird< / td >
< td > @twitter </ td >
< / tr >
< / tbody >
< / table >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2014-07-13 23:45:34 -07:00
2014-07-11 22:34:47 -07:00
## Striped rows
Use `.table-striped` to add zebra-striping to any table row within the `<tbody>` .
2018-03-14 16:44:38 +01:00
{% capture example %}
2014-07-11 22:34:47 -07:00
< table class = "table table-striped" >
< thead >
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2014-07-11 22:34:47 -07:00
< / tr >
< / thead >
< tbody >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 1< / th >
2014-07-11 22:34:47 -07:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo </ td >
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 2< / th >
2014-07-11 22:34:47 -07:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat </ td >
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 3< / th >
2014-07-11 22:34:47 -07:00
< td > Larry< / td >
< td > the Bird< / td >
< td > @twitter </ td >
< / tr >
< / tbody >
< / table >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2014-07-11 22:34:47 -07:00
2018-03-14 16:44:38 +01:00
{% capture example %}
2017-08-18 18:23:06 -07:00
< table class = "table table-striped table-dark" >
2016-05-11 16:28:28 -07:00
< thead >
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2016-05-11 16:28:28 -07:00
< / 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 >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2016-05-11 16:28:28 -07:00
2014-07-11 22:34:47 -07:00
## Bordered table
Add `.table-bordered` for borders on all sides of the table and cells.
2018-03-14 16:44:38 +01:00
{% capture example %}
2014-07-11 22:34:47 -07:00
< table class = "table table-bordered" >
< thead >
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2014-07-11 22:34:47 -07:00
< / tr >
< / thead >
< tbody >
< tr >
2014-12-18 22:59:47 -08:00
< th scope = "row" > 1< / th >
2014-07-11 22:34:47 -07:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo </ td >
< / tr >
< tr >
2014-12-18 22:59:47 -08:00
< th scope = "row" > 2< / th >
2014-07-11 22:34:47 -07:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat </ td >
< / tr >
< tr >
2017-12-22 16:49:57 -08:00
< th scope = "row" > 3< / th >
2014-07-11 22:34:47 -07:00
< td colspan = "2" > Larry the Bird< / td >
< td > @twitter </ td >
< / tr >
< / tbody >
< / table >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2014-07-11 22:34:47 -07:00
2018-03-14 16:44:38 +01:00
{% capture example %}
2017-08-18 18:23:06 -07:00
< table class = "table table-bordered table-dark" >
2016-05-11 16:28:28 -07:00
< thead >
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2016-05-11 16:28:28 -07:00
< / 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 >
2017-12-22 16:49:57 -08:00
< th scope = "row" > 3< / th >
2016-05-11 16:28:28 -07:00
< td colspan = "2" > Larry the Bird< / td >
< td > @twitter </ td >
< / tr >
< / tbody >
< / table >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2016-05-11 16:28:28 -07:00
2017-10-11 00:01:57 +05:30
## Borderless table
Add `.table-borderless` for a table without borders.
2018-03-14 16:44:38 +01:00
{% capture example %}
2017-10-11 00:01:57 +05:30
< table class = "table table-borderless" >
< thead >
< tr >
< th scope = "col" > #< / th >
2018-01-20 15:11:19 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2017-10-11 00:01:57 +05:30
< / 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 >
2018-01-20 15:11:19 -08:00
< th scope = "row" > 3< / th >
2017-10-11 00:01:57 +05:30
< td colspan = "2" > Larry the Bird< / td >
< td > @twitter </ td >
< / tr >
< / tbody >
< / table >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2017-10-11 00:01:57 +05:30
2018-01-20 15:11:19 -08:00
`.table-borderless` can also be used on dark tables.
2018-03-14 16:44:38 +01:00
{% capture example %}
2017-10-11 00:01:57 +05:30
< table class = "table table-borderless table-dark" >
< thead >
< tr >
< th scope = "col" > #< / th >
2018-01-20 15:11:19 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2017-10-11 00:01:57 +05:30
< / tr >
< / thead >
2016-05-11 16:28:28 -07:00
< 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 >
2018-01-20 15:11:19 -08:00
< th scope = "row" > 3< / th >
2016-05-11 16:28:28 -07:00
< td colspan = "2" > Larry the Bird< / td >
< td > @twitter </ td >
< / tr >
< / tbody >
< / table >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2016-05-11 16:28:28 -07:00
2014-07-11 22:34:47 -07:00
## Hoverable rows
Add `.table-hover` to enable a hover state on table rows within a `<tbody>` .
2018-03-14 16:44:38 +01:00
{% capture example %}
2014-07-11 22:34:47 -07:00
< table class = "table table-hover" >
< thead >
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2014-07-11 22:34:47 -07:00
< / tr >
< / thead >
< tbody >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 1< / th >
2014-07-11 22:34:47 -07:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo </ td >
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 2< / th >
2014-07-11 22:34:47 -07:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat </ td >
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 3< / th >
2014-07-11 22:34:47 -07:00
< td colspan = "2" > Larry the Bird< / td >
< td > @twitter </ td >
< / tr >
< / tbody >
< / table >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2014-07-11 22:34:47 -07:00
2018-03-14 16:44:38 +01:00
{% capture example %}
2017-08-18 18:23:06 -07:00
< table class = "table table-hover table-dark" >
2016-05-11 16:28:28 -07:00
< thead >
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2016-05-11 16:28:28 -07:00
< / 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 >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2016-05-11 16:28:28 -07:00
2014-09-17 22:14:27 -07:00
## Small table
2014-07-11 22:34:47 -07:00
2014-09-17 22:14:27 -07:00
Add `.table-sm` to make tables more compact by cutting cell padding in half.
2014-07-11 22:34:47 -07:00
2018-03-14 16:44:38 +01:00
{% capture example %}
2014-09-17 22:14:27 -07:00
< table class = "table table-sm" >
2014-07-11 22:34:47 -07:00
< thead >
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2014-07-11 22:34:47 -07:00
< / tr >
< / thead >
< tbody >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 1< / th >
2014-07-11 22:34:47 -07:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo </ td >
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 2< / th >
2014-07-11 22:34:47 -07:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat </ td >
2016-05-11 16:28:28 -07:00
< / tr >
< tr >
< th scope = "row" > 3< / th >
< td colspan = "2" > Larry the Bird< / td >
< td > @twitter </ td >
< / tr >
< / tbody >
< / table >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2016-05-11 16:28:28 -07:00
2018-03-14 16:44:38 +01:00
{% capture example %}
2017-08-18 18:23:06 -07:00
< table class = "table table-sm table-dark" >
2016-05-11 16:28:28 -07:00
< thead >
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2016-05-11 16:28:28 -07:00
< / 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 >
2014-07-11 22:34:47 -07:00
< / tr >
< tr >
2014-11-30 21:01:50 -08:00
< th scope = "row" > 3< / th >
2014-07-11 22:34:47 -07:00
< td colspan = "2" > Larry the Bird< / td >
< td > @twitter </ td >
< / tr >
< / tbody >
< / table >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2014-07-11 22:34:47 -07:00
## Contextual classes
Use contextual classes to color table rows or individual cells.
2015-04-16 14:07:20 -07:00
< div class = "bd-example" >
2014-07-11 22:34:47 -07:00
< table class = "table" >
< thead >
< tr >
2017-12-22 16:49:57 -08:00
< th scope = "col" > Class< / th >
< th scope = "col" > Heading< / th >
< th scope = "col" > Heading< / th >
2014-07-11 22:34:47 -07:00
< / tr >
< / thead >
< tbody >
2015-03-30 18:08:01 -07:00
< tr class = "table-active" >
2017-06-28 09:36:27 -07:00
< th scope = "row" > Active< / th >
2017-12-22 16:49:57 -08:00
< td > Cell< / td >
< td > Cell< / td >
2014-07-11 22:34:47 -07:00
< / tr >
< tr >
2017-06-28 09:36:27 -07:00
< th scope = "row" > Default< / th >
2017-12-22 16:49:57 -08:00
< td > Cell< / td >
< td > Cell< / td >
2014-07-11 22:34:47 -07:00
< / tr >
2017-06-28 09:36:27 -07:00
{% for color in site.data.theme-colors %}
< tr class = "table-{{ color.name }}" >
< th scope = "row" > {{ color.name | capitalize }}< / th >
2017-12-22 16:49:57 -08:00
< td > Cell< / td >
< td > Cell< / td >
2017-06-28 09:36:27 -07:00
< / tr > {% endfor %}
2014-07-11 22:34:47 -07:00
< / tbody >
< / table >
< / div >
{% highlight html %}
<!-- On rows -->
2015-03-30 18:08:01 -07:00
< tr class = "table-active" > ...< / tr >
2017-06-28 09:36:27 -07:00
{% for color in site.data.theme-colors %}
< tr class = "table-{{ color.name }}" > ...< / tr > {% endfor %}
2014-07-11 22:34:47 -07:00
<!-- On cells ( `td` or `th` ) -->
< tr >
2015-03-30 18:08:01 -07:00
< td class = "table-active" > ...< / td >
2017-06-28 09:36:27 -07:00
{% for color in site.data.theme-colors %}
< td class = "table-{{ color.name }}" > ...< / td > {% endfor %}
2014-07-11 22:34:47 -07:00
< / tr >
{% endhighlight %}
2017-08-18 18:23:06 -07:00
Regular table background variants are not available with the dark table, however, you may use [text or background utilities ]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/colors/ ) to achieve similar styles.
2016-05-08 14:15:34 -07:00
< div class = "bd-example" >
2017-08-18 18:23:06 -07:00
< table class = "table table-dark" >
2016-05-08 14:15:34 -07:00
< thead >
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > Heading< / th >
< th scope = "col" > Heading< / th >
2016-05-08 14:15:34 -07:00
< / tr >
< / thead >
< tbody >
< tr class = "bg-primary" >
< th scope = "row" > 1< / th >
2017-12-22 16:49:57 -08:00
< td > Cell< / td >
< td > Cell< / td >
2016-05-08 14:15:34 -07:00
< / tr >
< tr >
< th scope = "row" > 2< / th >
2017-12-22 16:49:57 -08:00
< td > Cell< / td >
< td > Cell< / td >
2016-05-08 14:15:34 -07:00
< / tr >
< tr class = "bg-success" >
< th scope = "row" > 3< / th >
2017-12-22 16:49:57 -08:00
< td > Cell< / td >
< td > Cell< / td >
2016-05-08 14:15:34 -07:00
< / tr >
< tr >
< th scope = "row" > 4< / th >
2017-12-22 16:49:57 -08:00
< td > Cell< / td >
< td > Cell< / td >
2016-05-08 14:15:34 -07:00
< / tr >
< tr class = "bg-info" >
< th scope = "row" > 5< / th >
2017-12-22 16:49:57 -08:00
< td > Cell< / td >
< td > Cell< / td >
2016-05-08 14:15:34 -07:00
< / tr >
< tr >
< th scope = "row" > 6< / th >
2017-12-22 16:49:57 -08:00
< td > Cell< / td >
< td > Cell< / td >
2016-05-08 14:15:34 -07:00
< / tr >
< tr class = "bg-warning" >
< th scope = "row" > 7< / th >
2017-12-22 16:49:57 -08:00
< td > Cell< / td >
< td > Cell< / td >
2016-05-08 14:15:34 -07:00
< / tr >
< tr >
< th scope = "row" > 8< / th >
2017-12-22 16:49:57 -08:00
< td > Cell< / td >
< td > Cell< / td >
2016-05-08 14:15:34 -07:00
< / tr >
< tr class = "bg-danger" >
< th scope = "row" > 9< / th >
2017-12-22 16:49:57 -08:00
< td > Cell< / td >
< td > Cell< / td >
2016-05-08 14:15:34 -07:00
< / tr >
< / tbody >
< / table >
< / div >
2016-05-08 14:16:23 -07:00
{% highlight html %}
<!-- On rows -->
< tr class = "bg-primary" > ...< / tr >
< tr class = "bg-success" > ...< / tr >
< tr class = "bg-warning" > ...< / tr >
< tr class = "bg-danger" > ...< / tr >
< tr class = "bg-info" > ...< / tr >
<!-- On cells ( `td` or `th` ) -->
< tr >
< td class = "bg-primary" > ...< / td >
< td class = "bg-success" > ...< / td >
< td class = "bg-warning" > ...< / td >
< td class = "bg-danger" > ...< / td >
< td class = "bg-info" > ...< / td >
< / tr >
{% endhighlight %}
2018-01-16 00:49:36 +02:00
{% include callout-warning-color-assistive-technologies.md %}
2016-05-08 14:15:34 -07:00
2018-01-03 07:42:03 +00:00
Create responsive tables by wrapping any `.table` with `.table-responsive{-sm|-md|-lg|-xl}` , making the table scroll horizontally at each `max-width` breakpoint of up to (but not including) 576px, 768px, 992px, and 1120px, respectively.
2017-11-20 05:13:37 -05:00
2018-01-16 00:49:36 +02:00
{% include callout-info-mediaqueries-breakpoints.md %}
2014-07-11 22:34:47 -07:00
2017-10-19 08:55:53 -07:00
## Captions
2017-09-04 15:35:24 -07:00
2017-11-25 02:13:39 +02:00
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.
2017-10-19 08:55:53 -07:00
2018-03-14 16:44:38 +01:00
{% capture example %}
2017-10-19 08:55:53 -07:00
< table class = "table" >
< caption > List of users< / caption >
< thead >
< tr >
< th scope = "col" > #< / th >
2017-12-22 16:49:57 -08:00
< th scope = "col" > First< / th >
< th scope = "col" > Last< / th >
< th scope = "col" > Handle< / th >
2017-10-19 08:55:53 -07:00
< / 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 >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2017-10-19 08:55:53 -07:00
## Responsive tables
2017-12-22 17:58:56 -08:00
Responsive tables allow tables to be scrolled horizontally with ease. Make any table responsive across all viewports by wrapping a `.table` with `.table-responsive` . Or, pick a maximum breakpoint with which to have a responsive table up to by using `.table-responsive{-sm|-md|-lg|-xl}` .
2014-07-11 22:34:47 -07:00
2018-01-16 00:49:36 +02:00
{% capture callout %}
2017-12-22 17:58:56 -08:00
##### Vertical clipping/truncation
2015-04-16 16:56:40 -07:00
Responsive tables make use of `overflow-y: hidden` , which clips off any content that goes beyond the bottom or top edges of the table. In particular, this can clip off dropdown menus and other third-party widgets.
2018-01-16 00:49:36 +02:00
{% endcapture %}
{% include callout.html content=callout type="warning" %}
2015-04-16 16:56:40 -07:00
2017-10-19 08:55:53 -07:00
### Always responsive
2017-12-22 17:58:56 -08:00
Across every breakpoint, use `.table-responsive` for horizontally scrolling tables.
2015-04-16 14:07:20 -07:00
< div class = "bd-example" >
2017-12-22 17:58:56 -08:00
< 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 >
{% highlight html %}
< div class = "table-responsive" >
< table class = "table" >
...
2016-11-26 01:45:40 -08:00
< / table >
2017-12-22 17:58:56 -08:00
< / div >
{% endhighlight %}
### 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.
2014-07-11 22:34:47 -07:00
2018-07-15 22:51:47 -07:00
**These tables may appear broken until their responsive styles apply at specific viewport widths.**
2017-12-22 17:58:56 -08:00
{% for bp in site.data.breakpoints %}{% unless bp.breakpoint == "xs" %}
2018-07-15 22:51:47 -07:00
< div class = "bd-example" >
2017-12-22 17:58:56 -08:00
< div class = "table-responsive{{ bp.abbr }}" >
< table class = "table" >
2016-11-26 01:45:40 -08:00
< thead >
< tr >
2017-09-04 19:40:13 -03:00
< th scope = "col" > #< / th >
2017-12-22 17:58:56 -08:00
< 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 >
2018-03-12 13:38:09 +05:30
< th scope = "col" > Heading< / th >
< th scope = "col" > Heading< / th >
< th scope = "col" > Heading< / th >
2016-11-26 01:45:40 -08:00
< / tr >
< / thead >
< tbody >
< tr >
< th scope = "row" > 1< / th >
2017-12-22 17:58:56 -08:00
< td > Cell< / td >
< td > Cell< / td >
< td > Cell< / td >
< td > Cell< / td >
< td > Cell< / td >
2018-03-12 13:38:09 +05:30
< td > Cell< / td >
< td > Cell< / td >
< td > Cell< / td >
2016-11-26 01:45:40 -08:00
< / tr >
< tr >
< th scope = "row" > 2< / th >
2017-12-22 17:58:56 -08:00
< td > Cell< / td >
< td > Cell< / td >
< td > Cell< / td >
< td > Cell< / td >
< td > Cell< / td >
2018-03-12 13:38:09 +05:30
< td > Cell< / td >
< td > Cell< / td >
< td > Cell< / td >
2016-11-26 01:45:40 -08:00
< / tr >
< tr >
< th scope = "row" > 3< / th >
2017-12-22 17:58:56 -08:00
< td > Cell< / td >
< td > Cell< / td >
< td > Cell< / td >
< td > Cell< / td >
< td > Cell< / td >
2018-03-12 13:38:09 +05:30
< td > Cell< / td >
< td > Cell< / td >
< td > Cell< / td >
2016-11-26 01:45:40 -08:00
< / tr >
< / tbody >
2014-07-11 22:34:47 -07:00
< / table >
< / div >
2017-10-19 08:55:53 -07:00
< / div >
{% highlight html %}
2017-12-22 17:58:56 -08:00
< div class = "table-responsive{{ bp.abbr }}" >
< table class = "table" >
...
< / table >
< / div >
2017-10-19 08:55:53 -07:00
{% endhighlight %}
2018-07-15 22:51:47 -07:00
{% endunless %}{% endfor %}