| Adds basic styles to a table. |
|
| The container element for the table header row ( |
), used to identify table columns.
|
| The container element for table rows in the table body ( |
)。
|
| A container element for a group of table cells appearing on a single row ( |
or |
)。 |
|
|
The default table cell. |
|
|
A special table cell used to identify a column or row (depending on scope and position). It must be used within |
.
|
| A description or summary of the content stored in the table. |
Table classes
The following styles can be used with tables:
Example
<table class=">
table table-striped
"
<
caption
Striped table layout
caption
<
thead
<
tr
<
th
Name
th
<
th
City
th
<
th
Zip code
th
tr
thead
<
tbody
<
tr
<
td
Tanmay
td
<
td
Bangalore
td
<
td
560001
td
tr
<
tr
<
td
Sachin
td
<
td
Mumbai
td
<
td
400003
td
tr
<
tr
<
td
Uma
td
<
td
Pune
td
<
td
411027
td
tr
tbody
table
Try it »
The result is as follows:
Bordered table
By adding the .table-bordered class, you will see borders around every element, with the whole table having rounded corners, as shown in the example below:
Example
<table class=">
table table-bordered
"
<
caption
Bordered table layout
caption
<
thead
<
tr
<
th
Name
th
<
th
City
th
<
th
Zip code
th
tr
thead
<
tbody
<
tr
<
td
Tanmay
td
<
td
Bangalore
td
<
td
560001
td
tr
<
tr
<
td
Sachin
td
<
td
Mumbai
td
<
td
400003
td
tr
<
tr
<
td
Uma
td
<
td
Pune
td
<
td
411027
td
tr
tbody
table
Try it »
The result is as follows:
Hover table
By adding the .table-hover class, a light gray background appears when the pointer hovers over a row, as shown in the example below:
Example
<table class=">
table table-hover
"
<
caption
Hover table layout
caption
<
thead
<
tr
<
th
Name
th
<
th
City
th
<
th
Zip code
th
tr
thead
<
tbody
<
tr
<
td
Tanmay
td
<
td
Bangalore
td
<
td
560001
td
tr
<
tr
<
td
Sachin
td
<
td
Mumbai
td
<
td
400003
td
tr
<
tr
<
td
Uma
td
<
td
Pune
td
<
td
411027
td
tr
tbody
table
Try it »
The result is as follows:
Condensed table
By adding the *.table-condensed* class, the cell padding is halved to make the table look more compact, as shown in the example below. This is useful when you want information to look more compact.
Example
<table class=">
table table-condensed
"
<
caption
Condensed table layout
caption
<
thead
<
tr
<
th
Name
th
<
th
City
th
<
th
Zip code
th
tr
thead
<
tbody
<
tr
<
td
Tanmay
td
<
td
Bangalore
td
<
td
560001
td
tr
<
tr
<
td
Sachin
td
<
td
Mumbai
td
<
td
400003
td
tr
<
tr
<
td
Uma
td
<
td
Pune
td
<
td
411027
td
tr
tbody
table
Try it »
The result is as follows:
Context Class
The contextual classes listed in the table below allow you to change the background color of table rows or individual cells.
| class |
Description |
Example |
| .table |
For any
add basic styles (horizontal dividers only)
| Try it |
| .table-striped |
in |
add zebra stripes within (not supported in IE8)
| Try it |
| .table-bordered |
add borders to all table cells |
Try it |
| .table-hover |
in |
enable the hover state on any row within
| Try it |
| .table-condensed |
make the table more compact |
Try it |
| combine all table classes |
Try it |
|
|
,
| and |
class
The classes in the table below can be applied to table rows or cells:
| class |
Description |
Example |
| .active |
Apply hover color to a row or cell |
Try it |
| .success |
Indicates a successful action |
Try it |
| .info |
Indicates an informational change |
Try it |
| .warning |
Indicates a warning action |
Try it |
| .danger |
Indicates a dangerous action |
Try it |
Basic table
If you want a basic table with only padding and horizontal dividers, add the class .table, as shown in the example below:
Example
<
table
class
=
"
table
"
<
caption
Basic table layout
caption
<
thead
<
tr
<
th
Name
th
<
th
City
th
tr
thead
<
tbody
<
tr
<
td
Tanmay
td
<
td
Bangalore
td
tr
<
tr
<
td
Sachin
td
<
td
Mumbai
td
tr
tbody
table
Try it »
The result is as follows:
Optional table classes
Besides the basic table markup and the .table class, there are other classes you can use to style the markup. These classes are introduced below.
Striped table
By adding the .table-striped class, you will see stripes on rows within |
, as shown in the example below:
| class |
Description |
| .active |
Apply hover color to a specific row or cell |
| .success |
Indicates a successful or positive action |
| .warning |
Indicates a warning that needs attention |
| .danger |
Indicates a dangerous or potentially negative action |
These classes can be applied to
|