Bootstrap | Tables | Set-1
Bootstrap provides us series of classes that can be used to apply various styling to tables such as changing the heading appearance, making the rows striped, adding or removing borders, making rows hoverable. Bootstrap also provides classes for making tables responsive.
- Simple table: To create simple Bootstrap table, add table class within the <table> tag as given below.
Example:
<!DOCTYPE html><htmllang="en"><head><!-- Required meta tags --><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1, shrink-to-fit=no"><!-- Bootstrap CSS --><linkrel="stylesheet"href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"crossorigin="anonymous"><title>Bootstrap | Tables</title><style>h1{color: green;text-align: center;}div{margin-top: 10px;}</style></head><body><divclass="container"><h1>GeeksForGeeks</h1><!-- Bootstrap table class --><tableclass="table"><thead><tr><thscope="col">S. No.</td><thscope="col">Name</td><thscope="col">City</td><thscope="col">Age</td></tr></thead><tbody><tr><thscope="row">1</td><td>Ajay</td><td>Patna</td><td>20</td></tr><tr><thscope="row">2</td><td>Rahul</td><td>Chandigarh</td><td>17</td></tr><tr><thscope="row">3</td><td>Parush</td><td>Kolkata</td><td>22</td></tr></tbody></table></div></body></html>chevron_rightfilter_noneOutput:

- Dark table: To make the table appear in dark background and light font, use the class table-dark along with the class table within <table> tag as given below.
Example:
<!DOCTYPE html><htmllang="en"><head><!-- Required meta tags --><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1, shrink-to-fit=no"><!-- Bootstrap CSS --><linkrel="stylesheet"href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"crossorigin="anonymous"><title>Bootstrap | Tables</title><style>h1{color: green;text-align: center;}div{margin-top: 10px;}</style></head><body><divclass="container"><h1>GeeksForGeeks</h1><!-- table, table-dark --><tableclass="table table-dark"><thead><tr><thscope="col">S. No.</td><thscope="col">Name</td><thscope="col">City</td><thscope="col">Age</td></tr></thead><tbody><tr><thscope="row">1</td><td>Ajay</td><td>Patna</td><td>20</td></tr><tr><thscope="row">2</td><td>Rahul</td><td>Chandigarh</td><td>17</td></tr><tr><thscope="row">3</td><td>Parush</td><td>Kolkata</td><td>22</td></tr></tbody></table></div></body></html>chevron_rightfilter_noneOutput:
- Heading appearance: To make the table heading appear in light gray color use the thead-light class within <thead> along with the table class within <table> or to make the table heading appear in dark gray color use the thead-dark class within <thead> along with the table class within <table>. See the example below for illustration.
Example:
<!DOCTYPE html><htmllang="en"><head><!-- Required meta tags --><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1, shrink-to-fit=no"><!-- Bootstrap CSS --><linkrel="stylesheet"href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"crossorigin="anonymous"><title>Bootstrap | Tables</title><style>h1{color: green;text-align: center;}div{margin-top: 10px;}</style></head><body><divclass="container"><h1>GeeksForGeeks</h1><!-- table, thead-light --><tableclass="table"><theadclass="thead-light"><tr><thscope="col">S. No.</td><thscope="col">Name</td><thscope="col">City</td><thscope="col">Age</td></tr></thead><tbody><tr><thscope="row">1</td><td>Ajay</td><td>Patna</td><td>20</td></tr><tr><thscope="row">2</td><td>Rahul</td><td>Chandigarh</td><td>17</td></tr><tr><thscope="row">3</td><td>Parush</td><td>Kolkata</td><td>22</td></tr></tbody></table><!-- table, thead-dark --><tableclass="table"><theadclass="thead-dark"><tr><thscope="col">S. No.</td><thscope="col">Name</td><thscope="col">City</td><thscope="col">Age</td></tr></thead><tbody><tr><thscope="row">1</td><td>Ajay</td><td>Patna</td><td>20</td></tr><tr><thscope="row">2</td><td>Rahul</td><td>Chandigarh</td><td>17</td></tr><tr><thscope="row">3</td><td>Parush</td><td>Kolkata</td><td>22</td></tr></tbody></table></div></body></html>chevron_rightfilter_noneOutput:

- Striped rows: To make the table appear in alternate dark and light rows, use the combination of classes table and table-striped within the <table> tag. We can also make the dark table appear in alternate light and dark rows by using the combination of classes table, table-dark, and table-striped within the <table> tag. See the example below for illustration.
Example:
<!DOCTYPE html><htmllang="en"><head><!-- Required meta tags --><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1, shrink-to-fit=no"><!-- Bootstrap CSS --><linkrel="stylesheet"href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"crossorigin="anonymous"><title>Bootstrap | Tables</title><style>h1{color: green;text-align: center;}div{margin-top: 10px;}</style></head><body><divclass="container"><h1>GeeksForGeeks</h1><!-- table, table-striped --><tableclass="table table-striped"><thead><tr><thscope="col">S. No.</td><thscope="col">Name</td><thscope="col">City</td><thscope="col">Age</td></tr></thead><tbody><tr><thscope="row">1</td><td>Ajay</td><td>Patna</td><td>20</td></tr><tr><thscope="row">2</td><td>Rahul</td><td>Chandigarh</td><td>17</td></tr><tr><thscope="row">3</td><td>Parush</td><td>Kolkata</td><td>22</td></tr></tbody></table><!-- table, table-striped, table-dark --><tableclass="table table-striped table-dark"><thead><tr><thscope="col">S. No.</td><thscope="col">Name</td><thscope="col">City</td><thscope="col">Age</td></tr></thead><tbody><tr><thscope="row">1</td><td>Ajay</td><td>Patna</td><td>20</td></tr><tr><thscope="row">2</td><td>Rahul</td><td>Chandigarh</td><td>17</td></tr><tr><thscope="row">3</td><td>Parush</td><td>Kolkata</td><td>22</td></tr></tbody></table></div></body></html>chevron_rightfilter_noneOutput:
- Bordered table: To make the table and its each cell surrounded by borders, use the class table-bordered along with the class table within <table> tag. We can also make the dark table and its each cell surrounded by borders by using the combination of classes table, table-dark, table-bordered within the <table> tag. See the example below for illustration.
Example:
<!DOCTYPE html><htmllang="en"><head><!-- Required meta tags --><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1, shrink-to-fit=no"><!-- Bootstrap CSS --><linkrel="stylesheet"href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"crossorigin="anonymous"><title>Bootstrap | Tables</title><style>h1{color: green;text-align: center;}div{margin-top: 10px;}</style></head><body><divclass="container"><h1>GeeksForGeeks</h1><!-- table, table-bordered --><tableclass="table table-bordered"><thead><tr><thscope="col">S. No.</td><thscope="col">Name</td><thscope="col">City</td><thscope="col">Age</td></tr></thead><tbody><tr><thscope="row">1</td><td>Ajay</td><td>Patna</td><td>20</td></tr><tr><thscope="row">2</td><td>Rahul</td><td>Chandigarh</td><td>17</td></tr><tr><thscope="row">3</td><td>Parush</td><td>Kolkata</td><td>22</td></tr></tbody></table><!-- table, table-bordered, table-dark --><tableclass="table table-bordered table-dark"><thead><tr><thscope="col">S. No.</td><thscope="col">Name</td><thscope="col">City</td><thscope="col">Age</td></tr></thead><tbody><tr><thscope="row">1</td><td>Ajay</td><td>Patna</td><td>20</td></tr><tr><thscope="row">2</td><td>Rahul</td><td>Chandigarh</td><td>17</td></tr><tr><thscope="row">3</td><td>Parush</td><td>Kolkata</td><td>22</td></tr></tbody></table></div></body></html>chevron_rightfilter_noneOutput:

Recommended Posts:
- Bootstrap | Tables | Set-2
- Bootstrap 4 | Tables
- Bootstrap (Part-3) | Buttons, Glyphicons, Tables
- Include Bootstrap in AngularJS using ng-bootstrap
- CSS | Tables
- HTML | Tables
- Bootstrap 4 | Spinners
- Bootstrap 4 | Tooltip
- Bootstrap 4 | Colors
- Bootstrap 4 | Buttons
- Bootstrap 4 | Popover
- Bootstrap | Scrollspy
- Bootstrap 4 | Cards
- Typography in Bootstrap
- Bootstrap 4 | Scrollspy
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



