w3school手册:http://www.w3schools.com/tags/att_table_cellspacing.asp

一直以来都发现自己对cellpadding&cellspacing的定义是不够清楚,所以很自然对padding&margin的定义也不是那么的清楚。可是,我对于padding&margin的理解还是比cellpadding&cellspacing深入一点的,毕竟,padding&margin只不是用来对同一个物体自己本身的描述,padding(一个块元素的内边距,就是该元素中的内容到该元素内侧边框的距离),margin(一个块元素的外边距,就是该元素自己本身的边框到父元素边框的距离)。

默认情况下,表格中的单元格是相互挤在在一起的。为了在你表格中的单元格添加一些空间的话,可以使用cellpadding&cellspacing。

cellspacing —— 控制着两个单元格之间的距离,尽管是没有官方默认值的,浏览器通常却会使用一个默认值为2,即在浏览器中,cellspacing的值就是会默认为2。

cellpadding —— 控制单元格中内容与单元格内四周之间的距离,默认值是1。通常情况下,cellpadding比cellspacing可以更加的有效扩大表格内容。

原文链接:http://www.htmlcodetutorial.com/tables/index_famsupp_29.html

How to set cellspacing and cellpadding in css ?

http://stackoverflow.com/questions/339923/how-to-set-cellpadding-and-cellspacing-in-css

For controlling "cellpadding" in CSS, you can simply use padding on table cells. E.g. for 10px of "cellpadding":

td {
padding: 10px;
}

For "cellspacing", you can apply the border-spacing CSS property to your table. E.g. for 10px of "cellspacing":

table {
border-spacing: 10px;
border-collapse: separate;
}

This property will even allow separate horizontal and vertical spacing, something you couldn't do with old-school "cellspacing".

Issues in IE <= 7

This will work in almost all popular browsers except for Internet Explorer up through Internet Explorer 7, where you're almost out of luck. I say "almost" because these browsers still support the border-collapseproperty, which merges the borders of adjoining table cells. If you're trying to eliminate cellspacing (that is, cellspacing="0") then border-collapse:collapse should have the same effect: no space between table cells. This support is buggy, though, as it does not override an existing cellspacing HTML attribute on the table element.

In short: for non-Internet Explorer 5-7 browsers, border-spacing handles you. For Internet Explorer, if your situation is just right (you want 0 cellspacing and your table doesn't have it defined already), you can use border-collapse:collapse.

table {
border-spacing: 0;
border-collapse: collapse;
}

最新文章

  1. HDU 4006The kth great number(K大数 +小顶堆)
  2. 在yii框架中如何连接数据库mongodb
  3. July 30th, Week 31st Saturday, 2016
  4. Servlet编程-步步为营
  5. HADOOP在处理HIVE时权限错误的解决办法
  6. O2O难解餐饮行业趋势下行之困
  7. 教你pomeloclient包libpomelo增加cocos2d-x 3.0工程(Windows、Android、IOS平台)
  8. 实现DataTables搜索框查询结果高亮显示
  9. [Swift]LeetCode63. 不同路径 II | Unique Paths II
  10. .Net File类的操作
  11. 图像处理 Matlab实现线性点运算、非线性点运算、点运算与直方图、直方图均衡化
  12. Python学习之旅(十)
  13. javascript 正则表达式的使用
  14. mac必装工具以及mac使用介绍
  15. 如何把连接字符串放到App.cfg配置文件中
  16. 总结this指向问题
  17. C++设计模式 -- 解析和实现
  18. 设计模式学习总结(八)策略模式(Strategy)
  19. linux命令大全(转载)
  20. php暂停函数sleep()和usleep的区别

热门文章

  1. do{}while() ;异常语句
  2. URL转义字符
  3. 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property &#39;source&#39; to &#39;org.eclipse.jst.jee.server:Weixin&#39; did not find a matching property.
  4. Python issubclass() 函数
  5. 控制span的width属性及display属性值的选择
  6. 对于局部变量,text、ntext 和 image 数据类型无效
  7. [leetcode]381. Insert Delete GetRandom O(1) - Duplicates allowed常数时间插入删除取随机值
  8. 【SQL模板】四.插入/更新 列模板TSQL
  9. [Selenium]当DOM结构里面有iFrame,iFrame里面是html,怎么send keys to 里面的body,怎么用Assert进行验证?
  10. HTML5 history详解