2014-07-12 07:34:47 +02:00
---
layout: page
title: Tables
---
Due to the widespread use of tables across plugins like calendars and date pickers, we've designed our tables to be **opt-in** . Just add the base class `.table` to any `<table>` .
## Basic example
{% example html %}
< table class = "table" >
< thead >
< tr >
< th > #< / th >
< th > First Name< / th >
< th > Last Name< / th >
< th > Username< / th >
< / tr >
< / thead >
< tbody >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 1< / th >
2014-07-12 07:34:47 +02:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 2< / th >
2014-07-12 07:34:47 +02:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 3< / th >
2014-07-12 07:34:47 +02:00
< td > Larry< / td >
< td > the Bird< / td >
< td > @twitter< / td >
< / tr >
< / tbody >
< / table >
{% endexample %}
2014-07-14 09:23:46 +02:00
## Inverse table
{% example html %}
< table class = "table table-inverse" >
< thead >
< tr >
< th > #< / th >
< th > First Name< / th >
< th > Last Name< / th >
< th > Username< / th >
< / tr >
< / thead >
< tbody >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 1< / th >
2014-07-14 09:23:46 +02:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 2< / th >
2014-07-14 09:23:46 +02:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 3< / th >
2014-07-14 09:23:46 +02:00
< td > Larry< / td >
< td > the Bird< / td >
< td > @twitter< / td >
< / tr >
< / tbody >
< / table >
{% endexample %}
2014-07-14 08:45:34 +02:00
## Table head options
Use one of two modifier classes to make `<thead>` s appear light or dark gray.
{% example html %}
< 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 >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 1< / th >
2014-07-14 08:45:34 +02:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 2< / th >
2014-07-14 08:45:34 +02:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 3< / th >
2014-07-14 08:45:34 +02:00
< td > Larry< / td >
< td > the Bird< / td >
< td > @twitter< / td >
< / tr >
< / tbody >
< thead class = "thead-default" >
< tr >
< th > #< / th >
< th > First Name< / th >
< th > Last Name< / th >
< th > Username< / th >
< / tr >
< / thead >
< tbody >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 1< / th >
2014-07-14 08:45:34 +02:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 2< / th >
2014-07-14 08:45:34 +02:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 3< / th >
2014-07-14 08:45:34 +02:00
< td > Larry< / td >
< td > the Bird< / td >
< td > @twitter< / td >
< / tr >
< / tbody >
< / table >
{% endexample %}
2014-07-12 07:34:47 +02:00
## Striped rows
Use `.table-striped` to add zebra-striping to any table row within the `<tbody>` .
{% example html %}
< table class = "table table-striped" >
< thead >
< tr >
< th > #< / th >
< th > First Name< / th >
< th > Last Name< / th >
< th > Username< / th >
< / tr >
< / thead >
< tbody >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 1< / th >
2014-07-12 07:34:47 +02:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 2< / th >
2014-07-12 07:34:47 +02:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 3< / th >
2014-07-12 07:34:47 +02:00
< td > Larry< / td >
< td > the Bird< / td >
< td > @twitter< / td >
< / tr >
< / tbody >
< / table >
{% endexample %}
## Bordered table
Add `.table-bordered` for borders on all sides of the table and cells.
{% example html %}
< table class = "table table-bordered" >
< thead >
< tr >
< th > #< / th >
< th > First Name< / th >
< th > Last Name< / th >
< th > Username< / th >
< / tr >
< / thead >
< tbody >
< tr >
2014-12-19 07:59:47 +01:00
< th scope = "row" > 1< / th >
2014-07-12 07:34:47 +02:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo< / td >
< / tr >
< tr >
2014-12-19 07:59:47 +01:00
< th scope = "row" > 2< / th >
2014-07-12 07:34:47 +02:00
< td > Mark< / td >
< td > Otto< / td >
< td > @TwBootstrap< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 3< / th >
2014-07-12 07:34:47 +02:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 4< / th >
2014-07-12 07:34:47 +02:00
< td colspan = "2" > Larry the Bird< / td >
< td > @twitter< / td >
< / tr >
< / tbody >
< / table >
{% endexample %}
## Hoverable rows
Add `.table-hover` to enable a hover state on table rows within a `<tbody>` .
{% example html %}
< table class = "table table-hover" >
< thead >
< tr >
< th > #< / th >
< th > First Name< / th >
< th > Last Name< / th >
< th > Username< / th >
< / tr >
< / thead >
< tbody >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 1< / th >
2014-07-12 07:34:47 +02:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 2< / th >
2014-07-12 07:34:47 +02:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 3< / th >
2014-07-12 07:34:47 +02:00
< td colspan = "2" > Larry the Bird< / td >
< td > @twitter< / td >
< / tr >
< / tbody >
< / table >
{% endexample %}
2014-09-18 07:14:27 +02:00
## Small table
2014-07-12 07:34:47 +02:00
2014-09-18 07:14:27 +02:00
Add `.table-sm` to make tables more compact by cutting cell padding in half.
2014-07-12 07:34:47 +02:00
{% example html %}
2014-09-18 07:14:27 +02:00
< table class = "table table-sm" >
2014-07-12 07:34:47 +02:00
< thead >
< tr >
< th > #< / th >
< th > First Name< / th >
< th > Last Name< / th >
< th > Username< / th >
< / tr >
< / thead >
< tbody >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 1< / th >
2014-07-12 07:34:47 +02:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 2< / th >
2014-07-12 07:34:47 +02:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 3< / th >
2014-07-12 07:34:47 +02:00
< td colspan = "2" > Larry the Bird< / td >
< td > @twitter< / td >
< / tr >
< / tbody >
< / table >
{% endexample %}
## Contextual classes
Use contextual classes to color table rows or individual cells.
< div class = "table-responsive" >
< table class = "table table-bordered table-striped" >
< colgroup >
< col class = "col-xs-1" >
< col class = "col-xs-7" >
< / colgroup >
< thead >
< tr >
< th > Class< / th >
< th > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" >
2014-07-12 07:34:47 +02:00
< code > .active< / code >
2014-12-01 05:17:45 +01:00
< / th >
2014-07-12 07:34:47 +02:00
< td > Applies the hover color to a particular row or cell< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" >
2014-07-12 07:34:47 +02:00
< code > .success< / code >
2014-12-01 05:17:45 +01:00
< / th >
2014-07-12 07:34:47 +02:00
< td > Indicates a successful or positive action< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" >
2014-07-12 07:34:47 +02:00
< code > .info< / code >
2014-12-01 05:17:45 +01:00
< / th >
2014-07-12 07:34:47 +02:00
< td > Indicates a neutral informative change or action< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" >
2014-07-12 07:34:47 +02:00
< code > .warning< / code >
2014-12-01 05:17:45 +01:00
< / th >
2014-07-12 07:34:47 +02:00
< td > Indicates a warning that might need attention< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" >
2014-07-12 07:34:47 +02:00
< code > .danger< / code >
2014-12-01 05:17:45 +01:00
< / th >
2014-07-12 07:34:47 +02:00
< td > Indicates a dangerous or potentially negative action< / td >
< / tr >
< / tbody >
< / table >
< / div >
< div class = "bs-example" >
< table class = "table" >
< thead >
< tr >
< th > #< / th >
< th > Column heading< / th >
< th > Column heading< / th >
< th > Column heading< / th >
< / tr >
< / thead >
< tbody >
< tr class = "active" >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 1< / th >
2014-07-12 07:34:47 +02:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 2< / th >
2014-07-12 07:34:47 +02:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr class = "success" >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 3< / th >
2014-07-12 07:34:47 +02:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 4< / th >
2014-07-12 07:34:47 +02:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr class = "info" >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 5< / th >
2014-07-12 07:34:47 +02:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 6< / th >
2014-07-12 07:34:47 +02:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr class = "warning" >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 7< / th >
2014-07-12 07:34:47 +02:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 8< / th >
2014-07-12 07:34:47 +02:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr class = "danger" >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 9< / th >
2014-07-12 07:34:47 +02:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< / tbody >
< / table >
< / div >
{% highlight html %}
<!-- On rows -->
< tr class = "active" > ...< / tr >
< tr class = "success" > ...< / tr >
< tr class = "warning" > ...< / tr >
< tr class = "danger" > ...< / tr >
< tr class = "info" > ...< / tr >
<!-- On cells (`td` or `th` ) -->
< tr >
< td class = "active" > ...< / td >
< td class = "success" > ...< / td >
< td class = "warning" > ...< / td >
< td class = "danger" > ...< / td >
< td class = "info" > ...< / td >
< / tr >
{% endhighlight %}
## Responsive tables
Create responsive tables by wrapping any `.table` in `.table-responsive` to make them scroll horizontally on small devices (under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.
< div class = "bs-callout bs-callout-warning" >
< h4 > Firefox and fieldsets< / h4 >
< p > Firefox has some awkward fieldset styling involving < code > width< / code > that interferes with the responsive table. This cannot be overriden without a Firefox-specific hack that we < strong > don't< / strong > provide in Bootstrap:< / p >
{% highlight css %}
@-moz-document url-prefix() {
fieldset { display: table-cell; }
}
{% endhighlight %}
< p > For more information, read < a href = "http://stackoverflow.com/questions/17408815/fieldset-resizes-wrong-appears-to-have-unremovable-min-width-min-content/17863685#17863685" > this Stack Overflow answer< / a > .< / p >
< / div >
< div class = "bs-example" >
< div class = "table-responsive" >
< table class = "table" >
< thead >
< tr >
< th > #< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< / tr >
< / thead >
< tbody >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 1< / th >
2014-07-12 07:34:47 +02:00
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 2< / th >
2014-07-12 07:34:47 +02:00
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 3< / th >
2014-07-12 07:34:47 +02:00
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< / tr >
< / tbody >
< / table >
< / div >
< div class = "table-responsive" >
< table class = "table table-bordered" >
< thead >
< tr >
< th > #< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< / tr >
< / thead >
< tbody >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 1< / th >
2014-07-12 07:34:47 +02:00
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 2< / th >
2014-07-12 07:34:47 +02:00
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 3< / th >
2014-07-12 07:34:47 +02:00
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< / tr >
< / tbody >
< / table >
< / div >
< / div >
{% highlight html %}
< div class = "table-responsive" >
< table class = "table" >
...
< / table >
< / div >
{% endhighlight %}
2014-08-06 02:45:24 +02:00
### Reflow
{% example html %}
< table class = "table table-reflow" >
< thead >
< tr >
< th > #< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< th > Table heading< / th >
< / tr >
< / thead >
< tbody >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 1< / th >
2014-08-06 02:45:24 +02:00
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 2< / th >
2014-08-06 02:45:24 +02:00
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< / tr >
< tr >
2014-12-01 06:01:50 +01:00
< th scope = "row" > 3< / th >
2014-08-06 02:45:24 +02:00
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< td > Table cell< / td >
< / tr >
< / tbody >
< / table >
{% endexample %}