Use the .table
class to style a table.
π Example: Basic Table
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>John Doe</td>
<td>john@example.com</td>
</tr>
<tr>
<td>2</td>
<td>Jane Smith</td>
<td>jane@example.com</td>
</tr>
</tbody>
</table>
β Explanation:
.table
applies Bootstrap styling to the table.
<thead>
and <tbody>
separate headings and data rows.
Use .table-striped
to apply zebra striping to rows.
π Example: Striped Table
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Product</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Laptop</td>
<td>$1000</td>
</tr>
<tr>
<td>2</td>
<td>Phone</td>
<td>$500</td>
</tr>
</tbody>
</table>
Use .table-bordered
to add borders to table cells.
π Example: Bordered Table
<table class="table table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Country</th>
<th>Capital</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>USA</td>
<td>Washington, D.C.</td>
</tr>
<tr>
<td>2</td>
<td>UK</td>
<td>London</td>
</tr>
</tbody>
</table>
Use .table-hover
to highlight rows on hover.
π Example: Hover Table
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Role</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Alice</td>
<td>Developer</td>
</tr>
<tr>
<td>2</td>
<td>Bob</td>
<td>Designer</td>
</tr>
</tbody>
</table>
Use .table-responsive
to make tables scrollable on small screens.
π Example: Responsive Table
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Employee</th>
<th>Department</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Chris</td>
<td>Marketing</td>
</tr>
<tr>
<td>2</td>
<td>Emma</td>
<td>Sales</td>
</tr>
</tbody>
</table>
</div>
Use .list-group
and .list-group-item
to create a stylish list.
π Example: Basic List Group
<ul class="list-group">
<li class="list-group-item">Item 1</li>
<li class="list-group-item">Item 2</li>
<li class="list-group-item">Item 3</li>
</ul>
β Explanation:
.list-group
wraps the list.
.list-group-item
styles individual items.
Add .active
to highlight an item.
Use .disabled
to disable an item.
π Example: Active & Disabled List Items
<ul class="list-group">
<li class="list-group-item active">Active Item</li>
<li class="list-group-item">Regular Item</li>
<li class="list-group-item disabled">Disabled Item</li>
</ul>
Use <a>
inside a .list-group
to create clickable links.
π Example: Clickable List Items
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action">Home</a>
<a href="#" class="list-group-item list-group-item-action">Services</a>
<a href="#" class="list-group-item list-group-item-action">Contact</a>
</div>
Use .badge
inside list items for notifications.
π Example: List with Badges
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
Messages <span class="badge bg-primary rounded-pill">5</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
Notifications <span class="badge bg-danger rounded-pill">3</span>
</li>
</ul>
Bootstrap Tables & Lists make it easy to display structured data with built-in styling and responsiveness. You can use striped rows, hover effects, borders, responsive layouts, and interactive lists to enhance your website's user experience. π