I have a table, constructed like this:
<table>
<tr> <td>1</td> <td>2</td> <td rowspan="4">3</td></tr>
<tr> <td>4</td> <td>5</td> </tr>
<tr> <td>6</td> <td>7</td> </tr>
<tr> <td>8</td> <td>9</td> </tr>
<tr height="100"><td colspan="2">10</td><td class="eleven">11</td> </tr>
</table>
Now the problem is within the last row. Whole row has a height set to 100px, so there is a plenty of room in TDs. In the very last TD I want to set an individual padding, so only the content "11" is padded from the top:
.eleven {
padding-top:15px;
}
Setting this causes the problem - the first TD in this row also gets padding-top:10px; Why and how to make only the 2nd one padded?
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.
You can easily set padding inside the table cells using the CSS padding property. It is a valid way to produce the same effect as the table's cellpadding attribute. Similarly, you can use the CSS border-spacing property to apply the spacing between adjacent table cell borders like the cellspacing attribute.
You can't add padding or margins to a 'tr' they are simply a mechanism to separate cells into rows. If you want space in the cell then you add padding as Ryan suggested and if you want space between the border of each cell then you use border-spacing. e.g. That will give vertical spacing of 10px between rows.
Why don't you wrap the content you want to be padded into a <div>
(onto which you will be applying the padding style) and put that <div>
into the <td>
?
<td>
<div style="padding-top: 15px;">
Content
</div>
</td>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With