Is it necessary to add cellspacing=“0” cellpadding=“0” in ?
后端 未结 3 2056
春和景丽
春和景丽 2021-02-18 17:17

Eric meyer reset css is suggesting \"tables still need \'cellspacing=\"0\"\' in the markup\". Is it necessary? and what is the benefit of border-collapse: collapse;

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-18 18:01

    There are two types of borders in a table, the table itself can have borders (outer borders and borders between cells), and each cell can have borders around them.

    Using border-collapse: collapse; means that two cells with the same border settings next to each other will only get a single set of bordering instead of a double, e.g. the right border of one cell will collapse with the left border on the next cell in the row.

    There wes no CSS style for the table border between cells until CSS 2, so it has to be disabled using the HTML attribute cellspacing="0" on the table to support older browsers like IE 7*. If there is table borders between the cells, the border collapsing will naturally not work as the borders are not next to each other.

    * I truly enjoyed the feeling of calling IE 7 an "older browser" ;)

提交回复
热议问题