LaRae White LaRae White - 5 months ago 50
CSS Question

How to add row top and bottom margins to asp.net gridview?

There aren't any attributes like CellPadding or CellSpacing that will accomplish this for me and when I try to add css to the grid tr's to change the top and bottom margins, they are ignored. How do I add a little bit of spacing between each generated row from the gridview?

Answer

Margin doesn't work on table elements, use padding, or like in below sample, set a top and/or bottom border on your tr

table {
  border-collapse: collapse; 
}
td {
  background: gray;
}
tr {
  border: 0px solid white;
  border-width: 10px 0;
}
<table>
  <tr>
    <td>
      Hello there
    </td>  
  </tr>  
  <tr>
    <td>
      Hello there
    </td>  
  </tr>  
  <tr>
    <td>
      Hello there
    </td>  
  </tr>  
</table>

Comments