Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a margin to a table row <tr> [duplicate]

Tags:

css

People also ask

How do I add a margin to a row in a table?

You cannot give margin to the table row. you can either give border-colapse and border spacing to the table or give border to table row and change its color to table background color.

How do you put padding on a table tr?

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.

Can you add padding to a TR?

You can't add padding or margins to a 'tr' they are simply a mechanism to separate cells into rows.


Table rows cannot have margin values. Can you increase the padding? That would work. Otherwise you could insert a <tr class="spacer"></tr> before and after the class="highlighted" rows.


The border-spacing property will work for this particular case.

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

Reference.


You can't style the <tr>s themselves, but you can give the <td>s inside the "highlight" <tr>s a style, like this

tr.highlight td {padding-top: 10px; padding-bottom:10px}

line-height can be the possible solution

tr
{
    line-height:30px;
}

This isn't going to be exactly perfect though I was happy to discover that you can control the horizontal and vertical border-spacing separately:

table
{
 border-collapse: separate;
 border-spacing: 0 8px;
}