Standard HTML tables tend to look a bit dated. Adding a border to a table results in something that looks more like a waffle than anything else! I always use CSS to create a variety of formatting styles for tables. I almost always start with border-collapse.

HTML

The following HTML-only code:

<table border="1" cellpadding="4">
	<tr>
		<th>Oranges</th>
		<th>Lemons</th>
		<th>Bells of St Clement's</th>
	</tr>
	<tr>
		<td>Orange</td>
		<td>Yellow</td>
		<td>Yellow</td>
	</tr>
</table>

Will result in:

Screenshot of an unstyled HTML table with borders applied.
Screenshot of an HTML table with borders applied.

CSS

The border-collapse property can be set to collapse to give your tables a more modern look:

See the Pen Untitled by David Fox (@foxbeefly) on CodePen.


References:

  1. HTML Table Borders. (2022). Retrieved 8 October 2022, from https://www.w3schools.com/html/html_table_borders.asp
  2. CSS border-collapse property. (2022). Retrieved 8 October 2022, from https://www.w3schools.com/cssref/pr_border-collapse.asp

By MisterFoxOnline

Mister Fox AKA @MisterFoxOnline is an ICT, IT and CAT Teacher who has just finished training as a Young Engineers instructor. He has a passion for technology and loves to find solutions to problems using the skills he has learned in the course of his IT career.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.