Hatem
Hatem

Reputation: 493

How to use cellpadding and cellspacing on HTML5?

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; 
}

Upvotes: 15

Views: 90090

Answers (3)

Matt Parkins
Matt Parkins

Reputation: 24708

For cellspacing:

  1. Set border-spacing on the table, not on the td.
  2. Set border-collapse to separate.
#SearchTable {
   border-collapse: separate;
   border-spacing: 8px; 
}

Upvotes: 23

Binil
Binil

Reputation: 117

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;
}

Upvotes: 1

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201866

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).

Upvotes: 4

Related Questions