The HTML & CSS in this tutorial generate a very simple 3 column table like this :
There’s only 2 steps needed to install the table in any WordPress theme.
Step 1 : Add the following HTML to your WordPress editor.
<table class="wp-table">
<tr>
<th>First Name</th>
<th>Surname Name</th>
<th>Score</th>
</tr>
<tr>
<td>Matt</td>
<td>Pearson</td>
<td>99</td>
</tr>
<tr>
<td>Steve</td>
<td>Smith</td>
<td>64</td>
</tr>
<tr>
<td>Brian</td>
<td>Johnson</td>
<td>16</td>
</tr>
</table>
Step 2 : Add the following CSS to your child themes style.css file.
.wp-table tr:nth-child(odd) {
background-color: #fff;
}
.wp-table tr:nth-child(even) {
background-color: #f1f1f1;
}
.wp-table tr {
border-bottom: 1px solid #ddd;
}
.wp-table th:first-child,
.wp-table td:first-child {
padding-left: 16px;
}
.wp-table td,
.wp-table th {
padding: 8px 8px;
display: table-cell;
text-align: left;
vertical-align: top;
}
.wp-table th {
font-weight: bold;
}
.wp-table {
font-size: 13px!important;
border: 1px solid #ccc;
border-collapse: collapse;
border-spacing: 0;
width: 100%;
display: table;
}
Tested using the Genesis Sample child theme by StudioPress.
Leave a Reply