I have a table containing many rows. Some of these rows are
class="highlight"
and signify a row that needs to be styled differently and highlighted. What I'm trying to do is add some extra spacing before and after these rows so they appear slightly separated from the other rows.
I thought I could get this done with
margin-top:10px;margin-bottom:10px;
but it's not working. Anyone knows how to get this done, or if it could be done? Here's the HTML and I've set the 2nd tr in the tbody to class highlight.
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Value1</td>
<td>Value2</td>
</tr>
<tr class="highlight">
<td>Value1</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
</tr>
</tbody>
</table>
possible duplicate of CSS: how do I create a gap between rows in a table? andstackoverflow.com/questions/351058/… – j08691 May 21 '12 at 18:13
try this: tr.highlight td { position: relative; background-color: #EEEEEE; padding: 5px 0 5px 0; } – Sajmon May 21 '12 at 18:19
if you are using the
separated
box model, I obtained the effect you wanted playing with borders of cell elements (TD and TH), not TR like @Jrd suggested: tr.highlight td { border-top: 10px solid; border-bottom: 10px solid; border-color: transparent; } – Enrico M. Aug 7 '15 at 9:18