I have an HTML table. I need to have spacing between the table columns, but not the table rows.
If I use the cellspacing
CSS property it does it between both rows and columns. I also cannot use CSS in what I doing. I need to use pure HTML.
Use the border-spacing property on the table element to set the spacing between cells. Make sure border-collapse is set to separate (or there will be a single border between each cell instead of a separate border around each one that can have spacing between them).
The space between two rows in a table can be done using CSS border-spacing and border-collapse property. The border-spacing property is used to set the spaces between cells of a table and border-collapse property is used to specify whether the border of table is collapse or not.
To freeze the row/column we can use a simple HTML table and CSS. HTML: In HTML we can define the header row by <th> tag or we can use <td> tag also. Below example is using the <th> tag. We also put the table in DIV element to see the horizontal and vertical scrollbar by setting the overflow property of the DIV element.
The better approach uses Shredder's css rule: padding: 0 15px 0 15px only instead of inline css, define a css rule that applies to all tds. Do This by using a style tag in your page:
<style type="text/css"> td { padding: 0 15px; } </style>
or give the table a class like "paddingBetweenCols" and in the site css use
.paddingBetweenCols td { padding: 0 15px; }
The site css approach defines a central rule that can be reused by all pages.
If your doing to use the site css approach, it would be best to define a class like above and apply the padding to the class...unless you want all td's on the entire site to have the same rule applied.
Fiddle for using style tag
Fiddle for using site css
If you can use inline styling, you can set the left and right padding on each td
.. Or you use an extra td
between columns and set a number of non-breaking spaces as @rene kindly suggested.
http://jsfiddle.net/u5mN4/
http://jsfiddle.net/u5mN4/1/
Both are pretty ugly ;p css ftw
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