Table border css

Here's how to add a table border with CSS using JavaScript

By: Ajdin Imsirovic 19 October 2018

In this quick tip tutorial, we see how easy it is to add a border to a table HTML element using CSS, in all the different ways.

A close up of a calendar table with black borders Photo by Pixabay on

For this, we simply add the style attribute to the table html tag. The style attribute should have a value like this: border: 1px solid black.

Here’s an implementation with document.write():

document.write("<table style='border: 1px solid black'>");
document.write("<tr><td>one cell</td></tr>");

Feel free to check out my work here: