Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add space between cells (td) using css

Tags:

html

css

I am trying to add a table with space between cell as the background colour of the cell is white and the background color of the table is blue, you can easily see that padding and margin are not working (I am applying it to the td), it will only add space inside of the cell.

like image 810
Amra Avatar asked Jan 15 '10 10:01

Amra


People also ask

How do you put a space between TD in CSS?

The space between two rows in a table can be done using CSS border-spacing and border-collapse property. The border-spacing property is used to set the spaces between cells of a table and border-collapse property is used to specify whether the border of table is collapse or not.

How do I change the spacing between TD in HTML?

Use the border-spacing property on the table element to set the spacing between cells. Make sure border-collapse is set to separate (or there will be a single border between each cell instead of a separate border around each one that can have spacing between them).


2 Answers

You want border-spacing:

<table style="border-spacing: 10px;"> 

Or in a CSS block somewhere:

table {   border-spacing: 10px; } 

See quirksmode on border-spacing. Be aware that border-spacing does not work on IE7 and below.

like image 147
Dominic Rodger Avatar answered Sep 29 '22 14:09

Dominic Rodger


table {    border-spacing: 10px;  }  

This worked for me once I removed

border-collapse: separate; 

from my table tag.

like image 34
Kelly Avatar answered Sep 29 '22 12:09

Kelly