HTML table needs spacing between columns, not rows

后端 未结 5 1829
南旧
南旧 2021-02-06 20:10

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 bot

5条回答
  •  抹茶落季
    2021-02-06 20:59

    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:

    
    

    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

提交回复
热议问题