Card: Styling Tables

Styling Tables

Master the art of data presentation

With CSS, your tables can be not just functional but downright dazzling. Colors and backgrounds make them shine, while borders and outlines add just the right touch of elegance. After all, even a table deserves to indulge in a bit of grandeur!

Choosing the right fonts and alignments ensures your data isn’t just readable—it’s the star of the show.

Use color highlights and varying font sizes to create a subtle hierarchy, placing key information on the throne it deserves. And don’t forget: your table should shine on any device, whether it’s a massive monitor or the tiniest smartphone.

Token: Styling Tables

Table Magic

CSS Sorcery and Other Mysteries

With CSS, you can enchant your tables with custom borders. The border property lets you control thickness, color, and line style to suit your design whims. Prefer a cleaner look? The border-collapse property ensures no gaps between cells, keeping things tidy.

td {
    border: 1px solid grey;
    padding: 10px;
    text-align: center;
    vertical-align: bottom;
}

th:hover {
    background-color: red;
}

In this table, the entire width of the screen is filled. Borders collapse neatly, cells have padding, and text is aligned just right. On hover, th headers glow red, adding a fiery flair.

More Magical Table Properties:

  • text-align: center: Aligns text neatly in the middle of the cells—like letters sitting up straight and paying attention.
  • vertical-align: bottom: Drops content to the bottom of the cells for a more relaxed, casual vibe.
  • background-color: Adds a splash of color to your table cells, creating visual highlights.
  • hover: Changes cell backgrounds when the mouse hovers over them, offering interactive feedback—as if the cells are waving hello!
CSS
/* body */
body {
    font-family: Arial, Helvetica, sans-serif;
}

/* Basic Table Structure */
table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Arial', sans-serif;
}

/* Table Borders */
th,
td {
    border: 2px solid forestgreen;
    padding: 10px;
    text-align: left;
    vertical-align: middle;
}

/* Background and Text Colors */
thead {
    background-color: darkgreen;
    color: white;
}

tbody tr {
    background-color: lightgreen;
}

tfoot {
    background-color: forestgreen;
    color: white;
}

/* Hover Effect */
tbody tr:hover {
    background-color: yellowgreen;
    color: black;
}
Scroll to Top