9

I would like to style the table written below.

<table border="1"   cellspacing="10">
  <tr>
    <th>Month</th>
    <th>Savings</th>  
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>

The problem is that cellspacing sets the space between cells both horizontaly and verticaly, I would like it to be done only horizontaly. Is there a way to do this.

1
  • Can you try with CSS by setting padding-left and padding-right to your TDs Commented Oct 19, 2012 at 9:04

2 Answers 2

19

Use the border-spacing CSS property on the table. Browser support is fairly good (excluding mainly IE up to and including IE 7). Example:

table { border-spacing: 10px 0; }
Sign up to request clarification or add additional context in comments.

Comments

2

Try CSS

table td{

 padding:0px 10px 0px 10px; /* top right bottom left */

 }

1 Comment

Padding is inside cells. It’s different from spacing between cells, which is what this is about.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.