Bulma CSS provides different predefined Bulma table classes that are used to create a different table style. HTML <table>
element has followings structures:
<table class="table">
is the main container of the table.
thead
- It is an optional top part of the table.
tfoot
the optional bottom part of the table
tbody
the main content of the table
tr
each table row
th
a table cell heading
td
a table cell
Modifiers - Bulma provides different modifiers classes that are used along with .table
class. It displays the table in different styles.
You can create a table in Bulma CSS by assigning the .table
modifier class to the <table>
element base class. You can display a table row as a selected by assigning the .is-selected
modifier class to the <tr>
base class.
Name | Age |
---|---|
John Smith | 30 |
John Doe | 35 |
Source Code
<div class="container">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Smith</td>
<td>30</td>
</tr>
<tr>
<td>John Doe</td>
<td>35</td>
</tr>
</tbody>
</table>
</div>
Source Code : Output
Name | Age |
---|---|
John Smith | 30 |
John Doe | 35 |
To create a bordered table, just assign .is-bordered
modifier class to the <table>
element base class having .table
modifier class. These classes add borders to all the cells.
Name | Age |
---|---|
John Smith | 30 |
John Doe | 35 |
Source Code
<div class="container">
<table class="table is-bordered">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Smith</td>
<td>30</td>
</tr>
<tr>
<td>John Doe</td>
<td>35</td>
</tr>
</tbody>
</table>
</div>
Source Code : Output
Name | Age |
---|---|
John Smith | 30 |
John Doe | 35 |
To create striped table, assign .is-striped
modifier class to the <table>
element base class having .table
modifier class. These classes add stripes to the table.
Fruits | Price(Rs.) |
---|---|
Mango | 40 |
Orange | 60 |
Source Code
<div class="container">
<table class="table is-striped">
<thead>
<tr>
<th>Fruits</th>
<th>Price(Rs.)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mango</td>
<td>40</td>
</tr>
<tr>
<td>Orange</td>
<td>60</td>
</tr>
</tbody>
</table>
</div>
Source Code : Output
Fruits | Price(Rs.) |
---|---|
Mango | 40 |
Orange | 60 |
To make the table cell narrow, assign .table is-narrow
modifier class to the <table>
element base class.
Name | Age |
---|---|
John Smith | 40 |
Mithlesh Yadav | 35 |
Source Code
<div class="container">
<table class="table is-narrow">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Smith</td>
<td>40</td>
</tr>
<tr>
<td>Mithlesh Yadav</td>
<td>35</td>
</tr>
</tbody>
</table>
</div>
Source Code : Output
Name | Age |
---|---|
John Smith | 40 |
Mithlesh Yadav | 35 |
To create a table with hover effect on each rows, simply assign the .table is-hoverable
modifier class to the <table>
element base class.
Name | Age |
---|---|
John Smith | 40 |
Mithlesh Yadav | 35 |
Source Code
<div class="container">
<table class="table is-hoverable">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Smith</td>
<td>40</td>
</tr>
<tr>
<td>Mithlesh Yadav</td>
<td>35</td>
</tr>
</tbody>
</table>
</div>
Source Code : Output
Name | Age |
---|---|
John Smith | 40 |
Mithlesh Yadav | 35 |
You can create table with full width by assigning .table is-fullwidth
modifier class to the <table>
element base class having .table
modifier class.
Name | Age |
---|---|
John Smith | 40 |
Mithlesh Yadav | 35 |
Source Code
<div class="container">
<table class="table table is-fullwidth">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Smith</td>
<td>40</td>
</tr>
<tr>
<td>Mithlesh Yadav</td>
<td>35</td>
</tr>
</tbody>
</table>
</div>
Source Code : Output
Name | Age |
---|---|
John Smith | 40 |
Mithlesh Yadav | 35 |
To create a scrollable table, simply wrap the table inside the container having a .table-container
modifier class.
First Name | Last Name | Gender | Age | Education | Grade | Skilss | Experience | Country | City | Po | Zip | Contact | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Mithlesh | Kumar | Male | 27 | B.tect | A | Web Development | 10 | India | Kanpur | Kakadev | 202566 | 455xxxxxxx | Dilip | Kumar | Male | 25 | B.tect | A | Web Development | 10 | India | Kanpur | Kakadev | 202566 | 455xxxxxxx |
General Syntax
<div class="table-container">
<table class="table">
<!-- Your table content -->
</table>
</div>
Source Code
<div class="table-container">
<table class="table table is-fullwidth">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Smith</td>
<td>40</td>
</tr>
<tr>
<td>Mithlesh Yadav</td>
<td>35</td>
</tr>
</tbody>
</table>
</div>
Source Code : Output
Name | Age |
---|---|
John Smith | 40 |
Mithlesh Yadav | 35 |