Am trying to use CSS3 to set the cell-spacing and the cell-padding for my table since HTML5 doesn't support these attributes.
I have found many resources on the internet says that you should use border-spacing and padding using CSS.
Unfo. i tried all these tricks , but it seems that no thing changing at all. The spacing is very important because am including image structure on the different cell of the table.
So how i can solve it now ? plz need your help
#SearchTable
{
border-collapse: collapse;
padding:0px 0px 0px 0px;
}
#SearchTable td
{
padding:0;
border-spacing:0px 0px;
}
Answer: Use the CSS padding & border-spacing property As we know the table's cellpadding and cellspacing attributes are removed in HTML5. But, you can still set padding inside the table cells easily using the CSS padding property. This is a valid way to produce the same effect as table's cellpadding attribute.
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.
Cellpadding basically defines the space present between a table cell's border and the content present in it. Cellspacing basically defines the space present between individual adjacent cells. One can create it using the tag of HTML <table>, but it sets the type attribute to cellpadding.
For cellspacing:
#SearchTable {
border-collapse: separate;
border-spacing: 8px;
}
You have not set id=SearchTable
on the table, or you have some other stylesheet rules that override those that you specify. As such, the rules you posted are more than sufficient for the effect; you only need
#SearchTable
{
border-collapse: collapse;
}
#SearchTable td
{
padding:0;
}
(which are already in CSS2).
You need to set it like this. It worked for me.
#SearchTable {
border-spacing:2px 2px;
border-collapse:separate;
}
#SearchTable td {
border:1px solid black;
}
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