Components Lesson 7 of 12
Bootstrap Tables
Style tables with Bootstrap — table, table-striped, table-hover, table-bordered, colored rows, small tables, and responsive tables that scroll on phones.
Plain HTML tables look cramped. Add the class table and Bootstrap gives them spacing, lines and a clean look. More classes add stripes, hover effects and colors.
A basic table
<link rel="stylesheet" href="/vendor/bootstrap.min.css">
<div class="container py-3">
<table class="table">
<thead>
<tr><th>#</th><th>Name</th><th>Section</th><th>Average</th></tr>
</thead>
<tbody>
<tr><td>1</td><td>Ana Reyes</td><td>Rizal</td><td>91.50</td></tr>
<tr><td>2</td><td>Ben Santos</td><td>Mabini</td><td>84.00</td></tr>
<tr><td>3</td><td>Carla Cruz</td><td>Rizal</td><td>95.20</td></tr>
</tbody>
</table>
</div>
Variations
<link rel="stylesheet" href="/vendor/bootstrap.min.css">
<div class="container py-3">
<table class="table table-striped table-hover table-bordered table-sm align-middle">
<thead class="table-dark">
<tr><th>Item</th><th class="text-end">Price</th><th class="text-end">Stock</th></tr>
</thead>
<tbody>
<tr><td>Pandesal</td><td class="text-end">25.00</td><td class="text-end">40</td></tr>
<tr><td>Kape 3-in-1</td><td class="text-end">8.00</td><td class="text-end">200</td></tr>
<tr class="table-danger"><td>Chips</td><td class="text-end">15.00</td><td class="text-end">0</td></tr>
<tr><td>Itlog</td><td class="text-end">9.00</td><td class="text-end">90</td></tr>
</tbody>
</table>
</div>
| Class | Effect |
|---|---|
table-striped | Alternating row shading |
table-hover | Highlights the row under the mouse |
table-bordered | Borders on all cells |
table-sm | Less padding (compact) |
table-dark | Dark table or dark header |
table-success, table-danger… | Colored rows or cells |
Right-align number columns with text-end so digits line up, which makes prices and grades much easier to compare.
Responsive tables
Wide tables overflow small screens. Wrap them in table-responsive so they scroll sideways instead of breaking the page:
<link rel="stylesheet" href="/vendor/bootstrap.min.css">
<div class="container py-3">
<div class="table-responsive">
<table class="table table-striped text-nowrap">
<thead><tr><th>LRN</th><th>Name</th><th>Math</th><th>Science</th><th>English</th><th>Filipino</th><th>AP</th><th>MAPEH</th><th>Average</th></tr></thead>
<tbody>
<tr><td>136728140001</td><td>Ana Reyes</td><td>92</td><td>90</td><td>94</td><td>91</td><td>89</td><td>93</td><td>91.50</td></tr>
<tr><td>136728140002</td><td>Ben Santos</td><td>84</td><td>82</td><td>86</td><td>85</td><td>83</td><td>84</td><td>84.00</td></tr>
</tbody>
</table>
</div>
</div>
Captions and accessibility
<table class="table caption-top">
<caption>Grade 10 - Rizal, First Quarter</caption>
...
</table>
A <caption> describes the table for everyone, including screen reader users. caption-top puts it above the table.
Quick Quiz
Check what you learned. Walang grade ito, practice lang. 🙂
By Sir Reyel · Last updated 2026-12-04