Set cellpadding and cellspacing in CSS?

前端 未结 28 1015
暖寄归人
暖寄归人 2020-11-22 02:15

In an HTML table, the cellpadding and cellspacing can be set like this:

相关标签:
28条回答
  • 2020-11-22 02:39
    table
    {
        border-collapse: collapse; /* 'cellspacing' equivalent */
    }
    
    table td, table th
    {
        padding: 0; /* 'cellpadding' equivalent */
    }
    
    0 讨论(0)
  • 2020-11-22 02:42

    Just use border-collapse: collapse for your table, and padding for th or td.

    0 讨论(0)
  • 2020-11-22 02:43

    TBH. For all the fannying around with CSS you might as well just use cellpadding="0" cellspacing="0" since they are not deprecated...

    Anyone else suggesting margins on <td>'s obviously has not tried this.

    0 讨论(0)
  • 2020-11-22 02:43
    table {
        border-spacing: 4px; 
        color: #000; 
        background: #ccc; 
    }
    td {
        padding-left: 4px;
    }
    
    0 讨论(0)
提交回复
热议问题