是否有必要添加cellspacing ="0"? cellpadding ="0"在< table>中? [英] Is it necessary to add cellspacing="0" cellpadding="0" in <table>?

查看:164
本文介绍了是否有必要添加cellspacing ="0"? cellpadding ="0"在< table>中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Eric Meyer重置CSS建议表在标记中仍需要'cellspacing ="0"'".有必要吗? border-collapse: collapse有什么好处;和border-spacing: 0;?

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; and border-spacing: 0;?

这只是建议使用cellspacing,而表具有另一个称为cellpadding的属性?

and it's only suggesting to use cellspacing, while table has another property called cellpadding?

/* tables still need 'cellspacing="0"' in the markup */
table {
        border-collapse: collapse;
        border-spacing: 0;
}

不建议使用

推荐答案

cellpadding,因为padding css属性足以覆盖cellpadding表属性的默认属性.就像另一个答案所说的那样,在较旧的浏览器中没有cellspacing的兼容CSS属性,而将HTML属性作为将此设置完全重置"为0的唯一方法.对于支持此功能的浏览器,border-spacing: 0;会照顾到这一点.它.

cellpadding is not suggested because the padding css property sufficiently overrides the default properties for the cellpadding table attribute. As the other answer says, there is no compatible CSS property for cellspacing in older browsers, leaving an HTML attribute as the only way to completely "reset" this setting to 0. border-spacing: 0; takes care of this for browsers which do support it.

关于border-collapse—默认情况下,每个表格单元格都有自己的边框,并且collapse会将相邻单元格之间的边框合并在一起,从而给出(通常为单像素)网格的外观,而cellspacing="0"则无法通过其他方式实现.在普遍支持border-collapse之前,这就是为什么您会看到带有cellspacing="1"且表的背景颜色为白色,而表单元格的背景为白色的表的原因.

As for border-collapse — by default, table cells each have their own border, and collapse will merge the borders between adjacent cells together, giving the appearance of a (usually single-pixel) grid, which isn't achievable any other way when cellspacing="0". Before border-collapse was commonly supported, this is why you'd see tables with cellspacing="1" and a background color on the table, and white backgrounds on table cells.

border-collapse:collapse;之所以位于reset.css中,仅仅是因为它是最常见的所需结果.如果您不希望使用此模式,则可以将其从reset.css中删除.

border-collapse:collapse; is in the reset.css simply because it is the most common desired result. If you don't want this mode, you'd be fine removing this from the reset.css.

这篇关于是否有必要添加cellspacing ="0"? cellpadding ="0"在< table>中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆