Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set cellpadding and cellspacing in table with CSS? [duplicate]

Tags:

html

css

Can someone tell me how to change table cellpadding and cellspacing like you can do it in html with:

<table cellspacing="0" cellpadding="0">  

But how is it done with css?

like image 370
Sudipa Sengupta Avatar asked May 07 '13 12:05

Sudipa Sengupta


2 Answers

Use padding on the cells and border-spacing on the table. The former will give you cellpadding while the latter will give you cellspacing.

table { border-spacing: 5px; } /* cellspacing */  th, td { padding: 5px; } /* cellpadding */ 

jsFiddle Demo

like image 166
kapa Avatar answered Oct 30 '22 03:10

kapa


The padding inside a table-divider (TD) is a padding property applied to the cell itself.

CSS

td, th {padding:0} 

The spacing in-between the table-dividers is a space between cell borders of the TABLE. To make it effective, you have to specify if your table cells borders will 'collapse' or be 'separated'.

CSS

table, td, th {border-collapse:separate} table {border-spacing:6px} 

Try this : https://www.google.ca/search?num=100&newwindow=1&q=css+table+cellspacing+cellpadding+site%3Astackoverflow.com ( 27 100 results )

like image 32
Milche Patern Avatar answered Oct 30 '22 05:10

Milche Patern