reply View all Tutorials & Projects

How to Style HTML Tables with CSS

In this tutorial you'll learn how to create beautiful HTML tables using a bit of simple CSS. It also features the ability to "highlight" a row, making it easy for users to see important data.

Video Tutorial

Source Code

You can find the source code for this video below. Alternatively, browse it on CodePen.

* {
    /* Change your font family */
    font-family: sans-serif;

.content-table {
    border-collapse: collapse;
    margin: 25px 0;
    font-size: 0.9em;
    min-width: 400px;
    border-radius: 5px 5px 0 0;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);

.content-table thead tr {
    background-color: #009879;
    color: #ffffff;
    text-align: left;
    font-weight: bold;

.content-table th,
.content-table td {
    padding: 12px 15px;

.content-table tbody tr {
    border-bottom: 1px solid #dddddd;

.content-table tbody tr:nth-of-type(even) {
    background-color: #f3f3f3;

.content-table tbody tr:last-of-type {
    border-bottom: 2px solid #009879;

.content-table tbody {
    font-weight: bold;
    color: #009879;
<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>How to Style HTML Tables with CSS</title>
    <link rel="stylesheet" href="css/main.css">
    <table class="content-table">
          <tr class="active-row">

If you have any questions about this code, please leave a comment on the video.