<table border="0" style="padding:10px;width: 960px;border-collapse: collapse;">
<tbody>
<tr>
<td style="padding: 0"><img src="8.jpg" alt="" /></td>
<td style="padding: 0"><img src="98.jpg" alt="" /></td>
<td style="padding: 0"><img src="998.jpg" alt="" /></td>
<td style="padding: 0"><img src="1998.jpg" alt="" /></td>
</tr>
<tr>
<td style="background-color: #757575;">11194</td>
<td style="background-color: #757575;">11194</td>
<td style="background-color: #757575;">11194</td>
<td style="background-color: #757575;">11194</td>
</tr>
<tr>
<td style="padding: 0"><img src="8.jpg" alt="" /></td>
<td style="padding: 0"><img src="98.jpg" alt="" /></td>
<td style="padding: 0"><img src="998.jpg" alt="" /></td>
<td style="padding: 0"><img src="1998.jpg" alt="" /></td>
</tr>
</tbody>
</table>
why i can't add margin padding to the tr and td? i want the td (<td style="background-color: #757575;">11194</td>
) have margin-right.namely, each separated by some space. but can't work. how to correct it. and the second tr have some space between the following tr.
The key point here is that the tr element must be displayed as a block in order for padding to apply at the tr level. This totally screws with how table layout usually works. If you're doing this, you shouldn't be using a table - use a regular div .
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.
margin-right will not work if you set width to 100%. What you could do is : wrap table in a div tag.
margin specifications are ignored for table cells Refer: http://www.w3.org/TR/CSS2/tables.html and CSS Cell Margin
Internal table elements generate rectangular boxes with content and borders. Cells have padding as well. Internal table elements do not have margins.
If you wanna add padding, just set border-collapse:separate refer: http://www.w3schools.com/cssref/playit.asp?filename=playcss_border-collapse
I guess you are asking for border-collapse;
so try using it...
table {
border-collapse: collapse;
}
If you want to add padding
you can do it like
table.class_name td {
padding: 0;
}
The reason because you are giving padding on table
element and on td
and you are giving padding:0
Remove border-collapse: collapse
from table
element and you can handle padding and margin easily in this table.
See the demo fiddle for concepts: http://jsfiddle.net/GVt3z/
Note: Above fiddle is not containing exact answer.
See updated fiddle for margin-right space but with different technique.
http://jsfiddle.net/GVt3z/1/
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