For creating tables, Bootstrap provides a tidy layout. The following are some of the table components that Bootstrap supports:
Sr.No. | Tag & Description |
---|---|
1 | < table > Data in a tabular format is shown using this wrapper element. |
2 | < thead > To label table columns, a container element for table header rows (tr>) is used. |
3 | < tbody > In the table's body, there is a container element for table rows (tr>). |
4 | < tr > On a single row, a container element for a set of table cells (td> or th>). |
5 | < td > Default table cell. |
6 | < th > Labels for columns (or rows, depending on scope and location) are stored in a special table cell. It has to be used within a < thead > tag. |
7 | < caption > A description or summary of the contents of the table. |
Add the base class of.table to any table for a lovely, basic table style with just some light padding and horizontal dividers.
name | state |
---|---|
Rohit | Delhi |
Rohan | Mumbai |
There are a couple extra classes you may use to style the HTML in addition to the fundamental table markup and the.table class. The sections that follow will provide you an overview of all of these classes.
You may get stripes on rows within the tbody> by adding the.table-striped class.
Name | country | state |
---|---|---|
Rohit | India | Delhi |
Mohit | Sri_lanka | Ampara |
Rohan | India | Kolkata |
You may achieve borders around every element and rounded edges all around the table by using the.table-bordered class.
Name | country | state |
---|---|---|
Rohit | India | Delhi |
Mohit | Sri_lanka | Ampara |
Rohan | India | Kolkata |
When the pointer hovers over rows, the.table-hover class is applied, giving them a light grey backdrop.
Name | country | state |
---|---|---|
Rohit | India | Delhi |
Mohit | Sri_lanka | Ampara |
Rohan | India | Kolkata |
The.table-condensed class reduces row padding by half, resulting in a more compact table.
Name | country | state |
---|---|---|
Rohit | India | Delhi |
Mohit | Sri_lanka | Ampara |
Rohan | India | Kolkata |
You can change the background colour of your table rows or individual cells using the contextual classes listed in the table below.
Sr.No | Class & Description |
---|---|
1 | .active The hover colour is applied to a certain row or cell. |
2 | .success This symbol represents a successful or beneficial deed. |
3 | .warning Indicates a possible need for care. |
4 | .danger Indicates a possibly harmful or dangerous behaviour. |
These classes can be applied to < tr >, < td > or < th >.
Product | Payment Date | Status |
---|---|---|
Packet1 | 20/11/2021 | Pending |
Packet2 | 18/12/2021 | Delivered |
Packet3 | 18/9/2021 | In Call to confirm |
Packet4 | 20/12/2021 | Declined |
You can make any.table scroll horizontally on small devices by wrapping it in the.table-responsive class (under 768px). There is no difference in these tables when viewed on anything larger than 768px wide.
Product | Payment Date | Status |
---|---|---|
Packet1 | 20/11/2021 | Pending |
Packet2 | 18/12/2021 | Delivered |
Packet3 | 18/9/2021 | In Call to confirm |
Packet4 | 20/12/2021 | Declined |
|