[html] Space between two rows in a table?

Is this possible via CSS?

I'm trying

tr.classname {
  border-spacing: 5em;
}

to no avail. Maybe I'm doing something wrong?

This question is related to html css

The answer is


You need to use padding on your td elements. Something like this should do the trick. You can, of course, get the same result using a top padding instead of a bottom padding.

In the CSS code below, the greater-than sign means that the padding is only applied to td elements that are direct children to tr elements with the class spaceUnder. This will make it possible to use nested tables. (Cell C and D in the example code.) I'm not too sure about browser support for the direct child selector (think IE 6), but it shouldn't break the code in any modern browsers.

_x000D_
_x000D_
/* Apply padding to td elements that are direct children of the tr elements with class spaceUnder. */_x000D_
_x000D_
tr.spaceUnder>td {_x000D_
  padding-bottom: 1em;_x000D_
}
_x000D_
<table>_x000D_
  <tbody>_x000D_
    <tr>_x000D_
      <td>A</td>_x000D_
      <td>B</td>_x000D_
    </tr>_x000D_
    <tr class="spaceUnder">_x000D_
      <td>C</td>_x000D_
      <td>D</td>_x000D_
    </tr>_x000D_
    <tr>_x000D_
      <td>E</td>_x000D_
      <td>F</td>_x000D_
    </tr>_x000D_
  </tbody>_x000D_
</table>
_x000D_
_x000D_
_x000D_

This should render somewhat like this:

+---+---+
| A | B |
+---+---+
| C | D |
|   |   |
+---+---+
| E | F |
+---+---+

You can fill the <td/> elements with <div/> elements, and apply any margin to those divs that you like. For a visual space between the rows, you can use a repeating background image on the <tr/> element. (This was the solution I just used today, and it appears to work in both IE6 and FireFox 3, though I didn't test it any further.)

Also, if you're averse to modifying your server code to put <div/>s inside the <td/>s, you can use jQuery (or something similar) to dynamically wrap the <td/> contents in a <div/>, enabling you to apply the CSS as desired.


You need to use padding on your td elements. Something like this should do the trick. You can, of course, get the same result using a top padding instead of a bottom padding.

In the CSS code below, the greater-than sign means that the padding is only applied to td elements that are direct children to tr elements with the class spaceUnder. This will make it possible to use nested tables. (Cell C and D in the example code.) I'm not too sure about browser support for the direct child selector (think IE 6), but it shouldn't break the code in any modern browsers.

_x000D_
_x000D_
/* Apply padding to td elements that are direct children of the tr elements with class spaceUnder. */_x000D_
_x000D_
tr.spaceUnder>td {_x000D_
  padding-bottom: 1em;_x000D_
}
_x000D_
<table>_x000D_
  <tbody>_x000D_
    <tr>_x000D_
      <td>A</td>_x000D_
      <td>B</td>_x000D_
    </tr>_x000D_
    <tr class="spaceUnder">_x000D_
      <td>C</td>_x000D_
      <td>D</td>_x000D_
    </tr>_x000D_
    <tr>_x000D_
      <td>E</td>_x000D_
      <td>F</td>_x000D_
    </tr>_x000D_
  </tbody>_x000D_
</table>
_x000D_
_x000D_
_x000D_

This should render somewhat like this:

+---+---+
| A | B |
+---+---+
| C | D |
|   |   |
+---+---+
| E | F |
+---+---+

You can't change the margin of a table cell. But you CAN change the padding. Change the padding of the TD, which will make the cell larger and push the text away from the side with the increased padding. If you have border lines, however, it still won't be exactly what you want.


You can fill the <td/> elements with <div/> elements, and apply any margin to those divs that you like. For a visual space between the rows, you can use a repeating background image on the <tr/> element. (This was the solution I just used today, and it appears to work in both IE6 and FireFox 3, though I didn't test it any further.)

Also, if you're averse to modifying your server code to put <div/>s inside the <td/>s, you can use jQuery (or something similar) to dynamically wrap the <td/> contents in a <div/>, enabling you to apply the CSS as desired.


Here this works smoothly:

#myOwnTable td { padding: 6px 0 6px 0;}

I suppose you could work out a more finely-grained layout by specifying which td if need be.


since I have a background image behind the table, faking it with white padding wouldn't work. I opted to put an empty row in-between each row of content:

<tr class="spacer"><td></td></tr>

then use css to give the spacer rows a certain height and transparent background.


Here's a simple and elegant solution, with a few caveats:

  • You can't actually make the gaps transparent, you need to give them a specific color.
  • You can't round the corners of the borders above & below the gaps
  • You need to know the padding and borders of your table cells

With that in mind, try this:

td {padding:5px 8px;border:2px solid blue;background:#E0E0E0}  /* lets say the cells all have this padding and border, and the gaps should be white */

tr.gapbefore td {overflow:visible}
tr.gapbefore td::before,
tr.gapbefore th::before
{
  content:"";
  display:block;
  position:relative;
  z-index:1;
  width:auto;
  height:0;
  padding:0;
  margin:-5px -10px 5px;  /* 5px = cell top padding, 10px = (cell side padding)+(cell side border width)+(table side border width) */
  border-top:16px solid white;  /* the size & color of the gap you want */
  border-bottom:2px solid blue; /* this replaces the cell's top border, so should be the same as that. DOUBLE IT if using border-collapse:separate */
}

What you're actually doing is sticking a rectangular ::before block into the top of all the cells in the row you want preceded by a gap. These blocks stick out of the cells a bit to overlap the existing borders, hiding them. These blocks are just a top and bottom border sandwiched together: The top border forms the gap, and the bottom border re-creates the appearance of the cells' original top border.

Note that if you have a border around the table itself as well as the cells, you'll need to further increase the horizontal -ve margin of of your 'blocks'. So for a 4px table border, you'd instead use:

margin:-5px -12px 5px;     /* 14px = original 10px + 2px for 'uncollapsed' part of table border */

And if your table uses border-collapse:separate instead of border-collapse:collapse, then you'll need to (a) use the full table border width:

margin:-5px -14px 5px;     /* 14px = original 10px + 4px full width of table border */

... and also (b) replace the double-width of border that now needs to appear below the gap:

border-bottom:4px solid blue;     /* i.e. 4px = cell top border + previous row's bottom border */

The technique is easily adapted to a .gapafter version, if you prefer, or to creating vertical (column) gaps instead of row gaps.

Here's a codepen where you can see it in action: https://codepen.io/anon/pen/agqPpW


Works for most latest browsers in 2015. Simple solution. It doesn't work for transparent, but unlike Thoronwen's answer, I can't get transparent to render with any size.

    tr {
      border-bottom:5em solid white;
    }

Simply put div inside the td and set the following styles of div:

margin-bottom: 20px;
height: 40px;
float: left;
width: 100%;

I realize this is an answer to an old thread and may not be the solution requested, but while all the suggested solutions did not do what I needed, this solution worked for me.

I had 2 table cells, one with background color, the other with a border color. The above solutions remove the border, so the cell on the right would appear to be floating in mid-air. The solution that did the trick was to replace the table, tr and td with divs and corresponding classes: table would be div id="table_replacer", tr would be div class="tr_replacer" and td would be div class="td_replacer" (change closing tags to divs as well obviously)

To get the solution for my problem the css is:

#table_replacer{display:table;}
.tr_replacer {border: 1px solid #123456;margin-bottom: 5px;}/*DO NOT USE display:table-row! It will destroy the border and the margin*/
.td_replacer{display:table-cell;}

Hope this helps someone.


You can fill the <td/> elements with <div/> elements, and apply any margin to those divs that you like. For a visual space between the rows, you can use a repeating background image on the <tr/> element. (This was the solution I just used today, and it appears to work in both IE6 and FireFox 3, though I didn't test it any further.)

Also, if you're averse to modifying your server code to put <div/>s inside the <td/>s, you can use jQuery (or something similar) to dynamically wrap the <td/> contents in a <div/>, enabling you to apply the CSS as desired.


A too late answer :)

If you apply float to tr elements, you can space between two rows with margin attribute.

table tr{
float: left
width: 100%;
}

tr.classname {
margin-bottom:5px;
}

I realize this is an answer to an old thread and may not be the solution requested, but while all the suggested solutions did not do what I needed, this solution worked for me.

I had 2 table cells, one with background color, the other with a border color. The above solutions remove the border, so the cell on the right would appear to be floating in mid-air. The solution that did the trick was to replace the table, tr and td with divs and corresponding classes: table would be div id="table_replacer", tr would be div class="tr_replacer" and td would be div class="td_replacer" (change closing tags to divs as well obviously)

To get the solution for my problem the css is:

#table_replacer{display:table;}
.tr_replacer {border: 1px solid #123456;margin-bottom: 5px;}/*DO NOT USE display:table-row! It will destroy the border and the margin*/
.td_replacer{display:table-cell;}

Hope this helps someone.


doing this shown above...

table tr{ float: left width: 100%; }  tr.classname { margin-bottom:5px; } 

removes vertical column alignment so be careful how you use it


You need to set border-collapse: separate; on the table; most browser default stylesheets start at border-collapse: collapse;, which ditches border spacing.

Also, border-spacing: goes on the TD, not the TR.

Try:

<html><head><style type="text/css">
    #ex    { border-collapse: separate; }
    #ex td { border-spacing: 1em; }
</style></head><body>
    <table id="ex"><tr><td>A</td><td>B</td></tr><tr><td>C</td><td>D</td></tr></table>
</body>

doing this shown above...

table tr{ float: left width: 100%; }  tr.classname { margin-bottom:5px; } 

removes vertical column alignment so be careful how you use it


Take a look at the border-collapse: separate attribute (default) and the border-spacing property.

First, you have to seperate them with border-collapse, then you can define the space between columns and rows with border-spacing .

Both of these CSS properties are actually well-supported on every browser, see here.

_x000D_
_x000D_
table     {border-collapse: separate;  border-spacing: 10px 20px;}_x000D_
_x000D_
table, _x000D_
table td,_x000D_
table th  {border: 1px solid black;}
_x000D_
<table>_x000D_
  <tr>_x000D_
    <td>Some text - 1</td>_x000D_
    <td>Some text - 1</td>_x000D_
  </tr>_x000D_
  <tr>_x000D_
    <td>Some text - 2</td>_x000D_
    <td>Some text - 2</td>_x000D_
  </tr>_x000D_
  <tr>_x000D_
    <td>Some text - 3</td>_x000D_
    <td>Some text - 3</td>_x000D_
  </tr>_x000D_
</table>
_x000D_
_x000D_
_x000D_


since I have a background image behind the table, faking it with white padding wouldn't work. I opted to put an empty row in-between each row of content:

<tr class="spacer"><td></td></tr>

then use css to give the spacer rows a certain height and transparent background.


Best way is to add tr between two tr like below,

_x000D_
_x000D_
<tr>
 <td height="5" colspan="2"></td>
</tr>
_x000D_
_x000D_
_x000D_


In the parent table, try setting

border-collapse:separate; 
border-spacing:5em;

Plus a border declaration, and see if this achieves your desired effect. Beware, though, that IE doesn't support the "separated borders" model.


You can't change the margin of a table cell. But you CAN change the padding. Change the padding of the TD, which will make the cell larger and push the text away from the side with the increased padding. If you have border lines, however, it still won't be exactly what you want.


Or just add a blank with the height of the margin in between the rows you would like to add the spacing


You have table with id albums with any data... I have omitted the trs and tds

<table id="albums" cellspacing="0">       
</table>

In the css:

table#albums 
{
    border-collapse:separate;
    border-spacing:0 5px;
}

You need to use padding on your td elements. Something like this should do the trick. You can, of course, get the same result using a top padding instead of a bottom padding.

In the CSS code below, the greater-than sign means that the padding is only applied to td elements that are direct children to tr elements with the class spaceUnder. This will make it possible to use nested tables. (Cell C and D in the example code.) I'm not too sure about browser support for the direct child selector (think IE 6), but it shouldn't break the code in any modern browsers.

_x000D_
_x000D_
/* Apply padding to td elements that are direct children of the tr elements with class spaceUnder. */_x000D_
_x000D_
tr.spaceUnder>td {_x000D_
  padding-bottom: 1em;_x000D_
}
_x000D_
<table>_x000D_
  <tbody>_x000D_
    <tr>_x000D_
      <td>A</td>_x000D_
      <td>B</td>_x000D_
    </tr>_x000D_
    <tr class="spaceUnder">_x000D_
      <td>C</td>_x000D_
      <td>D</td>_x000D_
    </tr>_x000D_
    <tr>_x000D_
      <td>E</td>_x000D_
      <td>F</td>_x000D_
    </tr>_x000D_
  </tbody>_x000D_
</table>
_x000D_
_x000D_
_x000D_

This should render somewhat like this:

+---+---+
| A | B |
+---+---+
| C | D |
|   |   |
+---+---+
| E | F |
+---+---+

You need to set border-collapse: separate; on the table; most browser default stylesheets start at border-collapse: collapse;, which ditches border spacing.

Also, border-spacing: goes on the TD, not the TR.

Try:

<html><head><style type="text/css">
    #ex    { border-collapse: separate; }
    #ex td { border-spacing: 1em; }
</style></head><body>
    <table id="ex"><tr><td>A</td><td>B</td></tr><tr><td>C</td><td>D</td></tr></table>
</body>

Here this works smoothly:

#myOwnTable td { padding: 6px 0 6px 0;}

I suppose you could work out a more finely-grained layout by specifying which td if need be.


Best way is to add tr between two tr like below,

_x000D_
_x000D_
<tr>
 <td height="5" colspan="2"></td>
</tr>
_x000D_
_x000D_
_x000D_


For creating an illusion of spacing between rows, apply background color to row and then create a thick border with white color so that a "space" is created :)

tr 
{
   background-color: #FFD700;
   border: 10px solid white;
}

Have you tried:

tr.classname { margin-bottom:5em; }

Alternatively, each td can be adjusted as well:

td.classname { margin-bottom:5em; }

or

 td.classname { padding-bottom:5em; }

The correct way to give spacing for tables is to use cellpadding and cellspacing e.g.

<table cellpadding="4">

Have you tried:

tr.classname { margin-bottom:5em; }

Alternatively, each td can be adjusted as well:

td.classname { margin-bottom:5em; }

or

 td.classname { padding-bottom:5em; }

The correct way to give spacing for tables is to use cellpadding and cellspacing e.g.

<table cellpadding="4">

Have you tried:

tr.classname { margin-bottom:5em; }

Alternatively, each td can be adjusted as well:

td.classname { margin-bottom:5em; }

or

 td.classname { padding-bottom:5em; }

Take a look at the border-collapse: separate attribute (default) and the border-spacing property.

First, you have to seperate them with border-collapse, then you can define the space between columns and rows with border-spacing .

Both of these CSS properties are actually well-supported on every browser, see here.

_x000D_
_x000D_
table     {border-collapse: separate;  border-spacing: 10px 20px;}_x000D_
_x000D_
table, _x000D_
table td,_x000D_
table th  {border: 1px solid black;}
_x000D_
<table>_x000D_
  <tr>_x000D_
    <td>Some text - 1</td>_x000D_
    <td>Some text - 1</td>_x000D_
  </tr>_x000D_
  <tr>_x000D_
    <td>Some text - 2</td>_x000D_
    <td>Some text - 2</td>_x000D_
  </tr>_x000D_
  <tr>_x000D_
    <td>Some text - 3</td>_x000D_
    <td>Some text - 3</td>_x000D_
  </tr>_x000D_
</table>
_x000D_
_x000D_
_x000D_


Simply put div inside the td and set the following styles of div:

margin-bottom: 20px;
height: 40px;
float: left;
width: 100%;

tr { 
    display: block;
    margin-bottom: 5px;
}

A too late answer :)

If you apply float to tr elements, you can space between two rows with margin attribute.

table tr{
float: left
width: 100%;
}

tr.classname {
margin-bottom:5px;
}

Have you tried:

tr.classname { margin-bottom:5em; }

Alternatively, each td can be adjusted as well:

td.classname { margin-bottom:5em; }

or

 td.classname { padding-bottom:5em; }

tr { 
    display: block;
    margin-bottom: 5px;
}

From Mozilla Developer Network:

The border-spacing CSS property specifies the distance between the borders of adjacent cells (only for the separated borders model). This is equivalent to the cellspacing attribute in presentational HTML, but an optional second value can be used to set different horizontal and vertical spacing.

That last part is often overseen. Example:

.your-table {
    border-collapse: separate; /* allow spacing between cell borders */
    border-spacing: 0 5px; /* NOTE: syntax is <horizontal value> <vertical value> */

UPDATE

I now understand that the OP wants specific, seperate rows to have increased spacing. I've added a setup with tbody elements that accomplishes that without ruining the semantics. However, I'm not sure if it is supported on all browsers. I made it in Chrome.

The example below is for showing how you can make it look like the table exists of seperate rows, full blown css sweetness. Also gave the first row more spacing with the tbody setup. Feel free to use!

Support notice: IE8+, Chrome, Firefox, Safari, Opera 4+

_x000D_
_x000D_
.spacing-table {_x000D_
  font-family: 'Helvetica', 'Arial', sans-serif;_x000D_
  font-size: 15px;_x000D_
  border-collapse: separate;_x000D_
  table-layout: fixed;_x000D_
  width: 80%;_x000D_
  border-spacing: 0 5px; /* this is the ultimate fix */_x000D_
}_x000D_
.spacing-table th {_x000D_
  text-align: left;_x000D_
  padding: 5px 15px;_x000D_
}_x000D_
.spacing-table td {_x000D_
  border-width: 3px 0;_x000D_
  width: 50%;_x000D_
  border-color: darkred;_x000D_
  border-style: solid;_x000D_
  background-color: red;_x000D_
  color: white;_x000D_
  padding: 5px 15px;_x000D_
}_x000D_
.spacing-table td:first-child {_x000D_
  border-left-width: 3px;_x000D_
  border-radius: 5px 0 0 5px;_x000D_
}_x000D_
.spacing-table td:last-child {_x000D_
  border-right-width: 3px;_x000D_
  border-radius: 0 5px 5px 0;_x000D_
}_x000D_
.spacing-table thead {_x000D_
  display: table;_x000D_
  table-layout: fixed;_x000D_
  width: 100%;_x000D_
}_x000D_
.spacing-table tbody {_x000D_
  display: table;_x000D_
  table-layout: fixed;_x000D_
  width: 100%;_x000D_
  border-spacing: 0 10px;_x000D_
}
_x000D_
<table class="spacing-table">_x000D_
  <thead>_x000D_
    <tr>_x000D_
        <th>Lead singer</th>_x000D_
        <th>Band</th>_x000D_
    </tr>_x000D_
  </thead>_x000D_
  <tbody>_x000D_
    <tr>_x000D_
        <td>Bono</td>_x000D_
        <td>U2</td>_x000D_
    </tr>_x000D_
  </tbody>_x000D_
  <tbody>_x000D_
    <tr>_x000D_
        <td>Chris Martin</td>_x000D_
        <td>Coldplay</td>_x000D_
    </tr>_x000D_
    <tr>_x000D_
        <td>Mick Jagger</td>_x000D_
        <td>Rolling Stones</td>_x000D_
    </tr>_x000D_
    <tr>_x000D_
        <td>John Lennon</td>_x000D_
        <td>The Beatles</td>_x000D_
    </tr>_x000D_
  </tbody>_x000D_
</table>
_x000D_
_x000D_
_x000D_


You can use line-height in the table:

<table style="width: 400px; line-height:50px;">

You can't change the margin of a table cell. But you CAN change the padding. Change the padding of the TD, which will make the cell larger and push the text away from the side with the increased padding. If you have border lines, however, it still won't be exactly what you want.


Here's a simple and elegant solution, with a few caveats:

  • You can't actually make the gaps transparent, you need to give them a specific color.
  • You can't round the corners of the borders above & below the gaps
  • You need to know the padding and borders of your table cells

With that in mind, try this:

td {padding:5px 8px;border:2px solid blue;background:#E0E0E0}  /* lets say the cells all have this padding and border, and the gaps should be white */

tr.gapbefore td {overflow:visible}
tr.gapbefore td::before,
tr.gapbefore th::before
{
  content:"";
  display:block;
  position:relative;
  z-index:1;
  width:auto;
  height:0;
  padding:0;
  margin:-5px -10px 5px;  /* 5px = cell top padding, 10px = (cell side padding)+(cell side border width)+(table side border width) */
  border-top:16px solid white;  /* the size & color of the gap you want */
  border-bottom:2px solid blue; /* this replaces the cell's top border, so should be the same as that. DOUBLE IT if using border-collapse:separate */
}

What you're actually doing is sticking a rectangular ::before block into the top of all the cells in the row you want preceded by a gap. These blocks stick out of the cells a bit to overlap the existing borders, hiding them. These blocks are just a top and bottom border sandwiched together: The top border forms the gap, and the bottom border re-creates the appearance of the cells' original top border.

Note that if you have a border around the table itself as well as the cells, you'll need to further increase the horizontal -ve margin of of your 'blocks'. So for a 4px table border, you'd instead use:

margin:-5px -12px 5px;     /* 14px = original 10px + 2px for 'uncollapsed' part of table border */

And if your table uses border-collapse:separate instead of border-collapse:collapse, then you'll need to (a) use the full table border width:

margin:-5px -14px 5px;     /* 14px = original 10px + 4px full width of table border */

... and also (b) replace the double-width of border that now needs to appear below the gap:

border-bottom:4px solid blue;     /* i.e. 4px = cell top border + previous row's bottom border */

The technique is easily adapted to a .gapafter version, if you prefer, or to creating vertical (column) gaps instead of row gaps.

Here's a codepen where you can see it in action: https://codepen.io/anon/pen/agqPpW


From Mozilla Developer Network:

The border-spacing CSS property specifies the distance between the borders of adjacent cells (only for the separated borders model). This is equivalent to the cellspacing attribute in presentational HTML, but an optional second value can be used to set different horizontal and vertical spacing.

That last part is often overseen. Example:

.your-table {
    border-collapse: separate; /* allow spacing between cell borders */
    border-spacing: 0 5px; /* NOTE: syntax is <horizontal value> <vertical value> */

UPDATE

I now understand that the OP wants specific, seperate rows to have increased spacing. I've added a setup with tbody elements that accomplishes that without ruining the semantics. However, I'm not sure if it is supported on all browsers. I made it in Chrome.

The example below is for showing how you can make it look like the table exists of seperate rows, full blown css sweetness. Also gave the first row more spacing with the tbody setup. Feel free to use!

Support notice: IE8+, Chrome, Firefox, Safari, Opera 4+

_x000D_
_x000D_
.spacing-table {_x000D_
  font-family: 'Helvetica', 'Arial', sans-serif;_x000D_
  font-size: 15px;_x000D_
  border-collapse: separate;_x000D_
  table-layout: fixed;_x000D_
  width: 80%;_x000D_
  border-spacing: 0 5px; /* this is the ultimate fix */_x000D_
}_x000D_
.spacing-table th {_x000D_
  text-align: left;_x000D_
  padding: 5px 15px;_x000D_
}_x000D_
.spacing-table td {_x000D_
  border-width: 3px 0;_x000D_
  width: 50%;_x000D_
  border-color: darkred;_x000D_
  border-style: solid;_x000D_
  background-color: red;_x000D_
  color: white;_x000D_
  padding: 5px 15px;_x000D_
}_x000D_
.spacing-table td:first-child {_x000D_
  border-left-width: 3px;_x000D_
  border-radius: 5px 0 0 5px;_x000D_
}_x000D_
.spacing-table td:last-child {_x000D_
  border-right-width: 3px;_x000D_
  border-radius: 0 5px 5px 0;_x000D_
}_x000D_
.spacing-table thead {_x000D_
  display: table;_x000D_
  table-layout: fixed;_x000D_
  width: 100%;_x000D_
}_x000D_
.spacing-table tbody {_x000D_
  display: table;_x000D_
  table-layout: fixed;_x000D_
  width: 100%;_x000D_
  border-spacing: 0 10px;_x000D_
}
_x000D_
<table class="spacing-table">_x000D_
  <thead>_x000D_
    <tr>_x000D_
        <th>Lead singer</th>_x000D_
        <th>Band</th>_x000D_
    </tr>_x000D_
  </thead>_x000D_
  <tbody>_x000D_
    <tr>_x000D_
        <td>Bono</td>_x000D_
        <td>U2</td>_x000D_
    </tr>_x000D_
  </tbody>_x000D_
  <tbody>_x000D_
    <tr>_x000D_
        <td>Chris Martin</td>_x000D_
        <td>Coldplay</td>_x000D_
    </tr>_x000D_
    <tr>_x000D_
        <td>Mick Jagger</td>_x000D_
        <td>Rolling Stones</td>_x000D_
    </tr>_x000D_
    <tr>_x000D_
        <td>John Lennon</td>_x000D_
        <td>The Beatles</td>_x000D_
    </tr>_x000D_
  </tbody>_x000D_
</table>
_x000D_
_x000D_
_x000D_


I stumbled upon this while struggling with a similar issue. I've found Varun Natraaj's answer to be quite helpful, but I would use a transparent border instead.

td { border: 1em solid transparent; }

Transparent borders still have width.


Works for most latest browsers in 2015. Simple solution. It doesn't work for transparent, but unlike Thoronwen's answer, I can't get transparent to render with any size.

    tr {
      border-bottom:5em solid white;
    }

In the parent table, try setting

border-collapse:separate; 
border-spacing:5em;

Plus a border declaration, and see if this achieves your desired effect. Beware, though, that IE doesn't support the "separated borders" model.


Ok, you can do

tr.classname td {background-color:red; border-bottom: 5em solid white}

Make sure the background color is set on the td rather than the row. This should work across most browsers... (Chrome, ie & ff tested)


In the parent table, try setting

border-collapse:separate; 
border-spacing:5em;

Plus a border declaration, and see if this achieves your desired effect. Beware, though, that IE doesn't support the "separated borders" model.


You can't change the margin of a table cell. But you CAN change the padding. Change the padding of the TD, which will make the cell larger and push the text away from the side with the increased padding. If you have border lines, however, it still won't be exactly what you want.


You have table with id albums with any data... I have omitted the trs and tds

<table id="albums" cellspacing="0">       
</table>

In the css:

table#albums 
{
    border-collapse:separate;
    border-spacing:0 5px;
}

For creating an illusion of spacing between rows, apply background color to row and then create a thick border with white color so that a "space" is created :)

tr 
{
   background-color: #FFD700;
   border: 10px solid white;
}

In the parent table, try setting

border-collapse:separate; 
border-spacing:5em;

Plus a border declaration, and see if this achieves your desired effect. Beware, though, that IE doesn't support the "separated borders" model.


Or just add a blank with the height of the margin in between the rows you would like to add the spacing


I stumbled upon this while struggling with a similar issue. I've found Varun Natraaj's answer to be quite helpful, but I would use a transparent border instead.

td { border: 1em solid transparent; }

Transparent borders still have width.


You can fill the <td/> elements with <div/> elements, and apply any margin to those divs that you like. For a visual space between the rows, you can use a repeating background image on the <tr/> element. (This was the solution I just used today, and it appears to work in both IE6 and FireFox 3, though I didn't test it any further.)

Also, if you're averse to modifying your server code to put <div/>s inside the <td/>s, you can use jQuery (or something similar) to dynamically wrap the <td/> contents in a <div/>, enabling you to apply the CSS as desired.


You may try to add separator row:

html:

<tr class="separator" />

css:

table tr.separator { height: 10px; }

Ok, you can do

tr.classname td {background-color:red; border-bottom: 5em solid white}

Make sure the background color is set on the td rather than the row. This should work across most browsers... (Chrome, ie & ff tested)


You can use line-height in the table:

<table style="width: 400px; line-height:50px;">

You may try to add separator row:

html:

<tr class="separator" />

css:

table tr.separator { height: 10px; }