HTML Table with Border Radius

HTML Table with Border Radius

Want to add a border radius? Import this stylesheet.

Have you ever wanted to add a border radius to an HTML table? If so, you know how difficult it is. Here is a simple solution.

:root {
  --borderColor: #c1c7d0;
  --borderRadius: 5px;

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;

table tr th,
table tr td {
  border-right: 1px solid var(--borderColor);
  border-bottom: 1px solid var(--borderColor);
  padding: 10px 15px;

table tr th:first-child,
table tr td:first-child {
  border-left: 1px solid var(--borderColor);

table tr th {
  background: #eee;
  text-align: left;
  border-top: solid 1px var(--borderColor);

table tr:first-child th:first-child {
  border-top-left-radius: var(--borderRadius);

table tr:first-child th:last-child {
  border-top-right-radius: var(--borderRadius);

table tr:last-child td:first-child {
  border-bottom-left-radius: var(--borderRadius);

table tr:last-child td:last-child {
  border-bottom-right-radius: var(--borderRadius);

Pro tip: I would recommend importing this as a global stylesheet to match all tables within your codebase.

I have this stylesheet up on GitHub Gist so you can use this snippet below in the HTML header element for importing.

<link rel="stylesheet" href="">

Thanks to this stack overflow thread for the idea.