Table and CSS
This example shows draws a formatted table.
by Michael Borck
HTML
<div class="labels">
<p>First</p>
<p>Last</p>
<p>Position</p>
</div>
<p class="tableend" />
<table>
<tr>
<th>First</th>
<th>Last</th>
<th>Position</th>
</tr>
<tr>
<td>Jane</td>
<td>Doe</td>
<td>Professor</td>
</tr>
<tr>
<td>John</td>
<td>Smith</td>
<td>Senior Lecturer</td>
</tr>
</table>
CSS
.labels>p {
vertical-align:middle;
float: left;
margin: 2px 0px 0px 2px;
}
.labels {
width: 372px;
margin: 0;
padding:0;
}
.tableend {
clear: both;
}
.labels>p, th {
font-weight: bold;
background-color: darkblue;
color: white;
}
td {
background-color: lightgray;
color: black;
}
th, td, .labels>p {
border-width: 1px; /* contributes 2 to width and height */
padding: 10px; /* contributes 20 to width and height */
font-size: 16px; /* contributes 16px to veritcal height */
width: 100px;
text-align: center;
border: 1px solid black;
}