2014-03-17 03:03:53 +01:00
< div class = "bs-docs-section" >
< h1 id = "tables" class = "page-header" > Tables< / h1 >
< h2 id = "tables-example" > Basic example< / h2 >
< p > For basic styling— light padding and only horizontal dividers— add the base class < code > .table< / code > to any < code > < table> < / code > . It may seem super redundant, but given the widespread use of tables for other plugins like calendars and date pickers, we've opted to isolate our custom table styles.< / p >
2014-11-25 02:09:32 +01:00
< div class = "bs-example" data-example-id = "simple-table" >
2014-03-17 03:03:53 +01:00
< table class = "table" >
2014-08-02 23:49:48 +02:00
< caption > Optional table caption.< / caption >
2014-03-17 03:03:53 +01:00
< thead >
< tr >
< th > #< / th >
< th > First Name< / th >
< th > Last Name< / th >
< th > Username< / th >
< / tr >
< / thead >
< tbody >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 1< / th >
2014-03-17 03:03:53 +01:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 2< / th >
2014-03-17 03:03:53 +01:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 3< / th >
2014-03-17 03:03:53 +01:00
< td > Larry< / td >
< td > the Bird< / td >
< td > @twitter< / td >
< / tr >
< / tbody >
< / table >
< / div > <!-- /example -->
{% highlight html %}
< table class = "table" >
...
< / table >
{% endhighlight %}
< h2 id = "tables-striped" > Striped rows< / h2 >
< p > Use < code > .table-striped< / code > to add zebra-striping to any table row within the < code > < tbody> < / code > .< / p >
2014-11-12 05:23:49 +01:00
< div class = "bs-callout bs-callout-danger" id = "callout-tables-striped-ie8" >
2014-03-17 03:03:53 +01:00
< h4 > Cross-browser compatibility< / h4 >
< p > Striped tables are styled via the < code > :nth-child< / code > CSS selector, which is not available in Internet Explorer 8.< / p >
< / div >
2014-11-25 02:09:32 +01:00
< div class = "bs-example" data-example-id = "striped-table" >
2014-03-17 03:03:53 +01:00
< 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-11-14 13:37:31 +01:00
< th scope = "row" > 1< / th >
2014-03-17 03:03:53 +01:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 2< / th >
2014-03-17 03:03:53 +01:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 3< / th >
2014-03-17 03:03:53 +01:00
< td > Larry< / td >
< td > the Bird< / td >
< td > @twitter< / td >
< / tr >
< / tbody >
< / table >
< / div > <!-- /example -->
{% highlight html %}
< table class = "table table-striped" >
...
< / table >
{% endhighlight %}
< h2 id = "tables-bordered" > Bordered table< / h2 >
< p > Add < code > .table-bordered< / code > for borders on all sides of the table and cells.< / p >
2014-11-25 02:09:32 +01:00
< div class = "bs-example" data-example-id = "bordered-table" >
2014-03-17 03:03:53 +01:00
< 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-11-14 13:37:31 +01:00
< th scope = "row" > 1< / th >
2014-03-17 03:03:53 +01:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 2< / th >
2014-03-17 03:03:53 +01:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 3< / th >
< td > Larry< / td >
< td > the Bird< / td >
2014-03-17 03:03:53 +01:00
< td > @twitter< / td >
< / tr >
< / tbody >
< / table >
< / div > <!-- /example -->
{% highlight html %}
< table class = "table table-bordered" >
...
< / table >
{% endhighlight %}
< h2 id = "tables-hover-rows" > Hover rows< / h2 >
< p > Add < code > .table-hover< / code > to enable a hover state on table rows within a < code > < tbody> < / code > .< / p >
2014-11-25 02:09:32 +01:00
< div class = "bs-example" data-example-id = "hoverable-table" >
2014-03-17 03:03:53 +01:00
< 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-11-14 13:37:31 +01:00
< th scope = "row" > 1< / th >
2014-03-17 03:03:53 +01:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 2< / th >
2014-03-17 03:03:53 +01:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 3< / th >
< td > Larry< / td >
< td > the Bird< / td >
2014-03-17 03:03:53 +01:00
< td > @twitter< / td >
< / tr >
< / tbody >
< / table >
< / div > <!-- /example -->
{% highlight html %}
< table class = "table table-hover" >
...
< / table >
{% endhighlight %}
< h2 id = "tables-condensed" > Condensed table< / h2 >
< p > Add < code > .table-condensed< / code > to make tables more compact by cutting cell padding in half.< / p >
2014-11-25 02:09:32 +01:00
< div class = "bs-example" data-example-id = "condensed-table" >
2014-03-17 03:03:53 +01:00
< table class = "table table-condensed" >
< thead >
< tr >
< th > #< / th >
< th > First Name< / th >
< th > Last Name< / th >
< th > Username< / th >
< / tr >
< / thead >
< tbody >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 1< / th >
2014-03-17 03:03:53 +01:00
< td > Mark< / td >
< td > Otto< / td >
< td > @mdo< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 2< / th >
2014-03-17 03:03:53 +01:00
< td > Jacob< / td >
< td > Thornton< / td >
< td > @fat< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 3< / th >
2014-03-17 03:03:53 +01:00
< td colspan = "2" > Larry the Bird< / td >
< td > @twitter< / td >
< / tr >
< / tbody >
< / table >
< / div > <!-- /example -->
{% highlight html %}
< table class = "table table-condensed" >
...
< / table >
{% endhighlight %}
< h2 id = "tables-contextual-classes" > Contextual classes< / h2 >
< p > Use contextual classes to color table rows or individual cells.< / p >
< 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-11-14 13:37:31 +01:00
< th scope = "row" >
2014-03-17 03:03:53 +01:00
< code > .active< / code >
2014-11-14 13:37:31 +01:00
< / th >
2014-03-17 03:03:53 +01:00
< td > Applies the hover color to a particular row or cell< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" >
2014-03-17 03:03:53 +01:00
< code > .success< / code >
2014-11-14 13:37:31 +01:00
< / th >
2014-03-17 03:03:53 +01:00
< td > Indicates a successful or positive action< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" >
2014-03-17 03:03:53 +01:00
< code > .info< / code >
2014-11-14 13:37:31 +01:00
< / th >
2014-03-17 03:03:53 +01:00
< td > Indicates a neutral informative change or action< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" >
2014-03-17 03:03:53 +01:00
< code > .warning< / code >
2014-11-14 13:37:31 +01:00
< / th >
2014-03-17 03:03:53 +01:00
< td > Indicates a warning that might need attention< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" >
2014-03-17 03:03:53 +01:00
< code > .danger< / code >
2014-11-14 13:37:31 +01:00
< / th >
2014-03-17 03:03:53 +01:00
< td > Indicates a dangerous or potentially negative action< / td >
< / tr >
< / tbody >
< / table >
< / div >
2014-11-25 02:09:32 +01:00
< div class = "bs-example" data-example-id = "contextual-table" >
2014-03-17 03:03:53 +01:00
< 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-11-14 13:37:31 +01:00
< th scope = "row" > 1< / th >
2014-03-17 03:03:53 +01:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 2< / th >
2014-03-17 03:03:53 +01:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr class = "success" >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 3< / th >
2014-03-17 03:03:53 +01:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 4< / th >
2014-03-17 03:03:53 +01:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr class = "info" >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 5< / th >
2014-03-17 03:03:53 +01:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 6< / th >
2014-03-17 03:03:53 +01:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr class = "warning" >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 7< / th >
2014-03-17 03:03:53 +01:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 8< / th >
2014-03-17 03:03:53 +01:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< tr class = "danger" >
2014-11-14 13:37:31 +01:00
< th scope = "row" > 9< / th >
2014-03-17 03:03:53 +01:00
< td > Column content< / td >
< td > Column content< / td >
< td > Column content< / td >
< / tr >
< / tbody >
< / table >
< / div > <!-- /example -->
{% 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 %}
2014-11-12 05:23:49 +01:00
< div class = "bs-callout bs-callout-warning" id = "callout-tables-context-accessibility" >
2014-10-30 17:45:33 +01:00
< h4 > Conveying meaning to assistive technologies< / h4 >
2014-11-12 04:49:44 +01:00
< p > Using color to add meaning to a table row or individual cell only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (the visible text in the relevant table row/cell), or is included through alternative means, such as additional text hidden with the < code > .sr-only< / code > class.< / p >
2014-10-30 17:45:33 +01:00
< / div >
2014-03-17 03:03:53 +01:00
< h2 id = "tables-responsive" > Responsive tables< / h2 >
2014-04-06 00:33:57 +02:00
< p > Create responsive tables by wrapping any < code > .table< / code > in < code > .table-responsive< / code > 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.< / p >
2014-05-23 06:12:13 +02:00
2014-12-31 03:16:16 +01:00
< div class = "bs-callout bs-callout-warning" id = "callout-tables-responsive-overflow" >
< h4 > Vertical clipping/truncation< / h4 >
< p > Responsive tables make use of < code > overflow-y: hidden< / code > , 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.< / p >
< / div >
2014-11-12 05:23:49 +01:00
< div class = "bs-callout bs-callout-warning" id = "callout-tables-responsive-ff-fieldset" >
2014-05-23 06:12:13 +02:00
< h4 > Firefox and fieldsets< / h4 >
2016-02-10 12:01:05 +01:00
< p > Firefox has some awkward fieldset styling involving < code > width< / code > that interferes with the responsive table. This cannot be overridden without a Firefox-specific hack that we < strong > don't< / strong > provide in Bootstrap:< / p >
2014-05-23 06:12:13 +02:00
{% highlight css %}
@-moz-document url-prefix() {
2014-05-23 06:39:47 +02:00
fieldset { display: table-cell; }
2014-05-23 06:12:13 +02:00
}
{% endhighlight %}
2015-05-17 11:43:04 +02:00
< p > For more information, read < a href = "https://stackoverflow.com/questions/17408815/fieldset-resizes-wrong-appears-to-have-unremovable-min-width-min-content/17863685#17863685" > this Stack Overflow answer< / a > .< / p >
2014-05-23 06:12:13 +02:00
< / div >
2014-11-25 02:09:32 +01:00
< div class = "bs-example" data-example-id = "simple-responsive-table" >
2014-03-17 03:03:53 +01:00
< 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-11-14 13:37:31 +01:00
< th scope = "row" > 1< / th >
2014-03-17 03:03:53 +01: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-11-14 13:37:31 +01:00
< th scope = "row" > 2< / th >
2014-03-17 03:03:53 +01: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-11-14 13:37:31 +01:00
< th scope = "row" > 3< / th >
2014-03-17 03:03:53 +01: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 > <!-- /.table - responsive -->
< 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-11-14 13:37:31 +01:00
< th scope = "row" > 1< / th >
2014-03-17 03:03:53 +01: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-11-14 13:37:31 +01:00
< th scope = "row" > 2< / th >
2014-03-17 03:03:53 +01: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-11-14 13:37:31 +01:00
< th scope = "row" > 3< / th >
2014-03-17 03:03:53 +01: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 > <!-- /.table - responsive -->
< / div > <!-- /example -->
{% highlight html %}
< div class = "table-responsive" >
< table class = "table" >
...
< / table >
< / div >
{% endhighlight %}
< / div >