Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase the distance between table columns in HTML?

Let's say I wanted to create a single-rowed table with 50 pixels in between each column, but 10 pixels padding on top and the bottom.

How would I do this in HTML/CSS?

like image 340
idude Avatar asked Jul 04 '13 11:07

idude


People also ask

How do I increase the space between columns in a table in HTML?

You can either add padding to the left of all columns except the first, or add padding to the right of all columns except the last. You should avoid adding padding to the right of the last column or to the left of the first as this will insert redundant white space.

How can I increase table spacing in HTML?

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.

How do I reduce the space between two columns in HTML table?

The space between the table cells is controlled by the CELLSPACING attribute in the TABLE tag. By setting CELLSPACING to zero, you can remove all the space between the cells of your table. This removes all the space between the cells of our table (see Figure 9). Figure 9 Our example with CELLSPACING=0.


1 Answers

There isn't any need for fake <td>s. Make use of border-spacing instead. Apply it like this:

HTML:

<table>   <tr>     <td>First Column</td>     <td>Second Column</td>     <td>Third Column</td>   </tr> </table> 

CSS:

table {   border-collapse: separate;   border-spacing: 50px 0; }  td {   padding: 10px 0; } 

See it in action.

like image 55
daniels Avatar answered Oct 10 '22 00:10

daniels