Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: how do I create a gap between rows in a table?

Tags:

html

css

Meaning making the resultant table look less like this:

 [===ROW===] [===ROW===] [===ROW===] [===ROW===] 

... and more like this:

 [===ROW===]  [===ROW===]  [===ROW===]  [===ROW===] 

I tried adding

margin-bottom:1em; 

to both td and tr but got nothing. Any ideas?

like image 954
MGOwen Avatar asked Aug 12 '09 04:08

MGOwen


People also ask

How do we add spacing between the cells in a table?

Cell padding is the space between cell borders and the content within a cell. To set cell padding in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <table> tag, with the CSS property padding.

How do you put a space between two rows in a div?

To give to space between two divs, just add display: flex in the parent element. Then add an justify-content: space-between after adding this you will see a space between two divs.


1 Answers

All you need:

table {     border-collapse: separate;     border-spacing: 0 1em; } 

That assumes you want a 1em vertical gap, and no horizontal gap. If you're doing this, you should probably also look at controlling your line-height.

Sort of weird that some of the answers people gave involve border-collapse: collapse, whose effect is the exact opposite of what the question asked for.

like image 179
John Haugeland Avatar answered Oct 02 '22 16:10

John Haugeland