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;
}

[翻译][HTML]CELLPADDING and CELLSPACING的更多相关文章

  1. CSS中表示cellpadding和cellspacing的方法

    本文和大家重点讨论一下用CSS来表示表格的cellpadding和cellspacing方法,表格的cellpadding和cellspacing我们经常会用一定的方式来清除默认样式,请看下文详细介绍 ...

  2. HTML cellpadding与cellspacing属性

    单元格(cell) -- 表格的内容 单元格边距(表格填充)(cellpadding) -- 代表单元格外面的一个距离,用于隔开单元格与单元格空间 单元格间距(表格间距)(cellspacing) - ...

  3. 在html5中不支持<table>的cellpadding 和 cellspacing ; 2) 如何用css实现 cellpadding, cellspacing ; 3) tr , th 是 有 border, 没有 padding 的.

    1.初始: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  4. cellspacing与cellpadding

    此文引用自cellpadding和cellspacing属性来控制表格边框的间距. 作者:nestea 巢(cell) -- 表格的内容 巢补白(表格填充)(cellpadding) -- 代表巢外面 ...

  5. CSS控制 table 的 cellpadding,cellspacing

    CSS 常规解决办法: 表格的 cellpadding 和 cellspacing 我们经常会用如下的方式来清除默认样式: <table cellspacing="0" ce ...

  6. 翻译:HTML5与HTML4的区别

    本文选译自:W3C Working Group Note: HTML5 Differences from HTML4. 解释一下W3C Working Group Note,作为"工作组笔记 ...

  7. [译]MVC网站教程(四):MVC4网站中集成jqGrid表格插件(系列完结)

    目录 1.   介绍 2.   软件环境 3.   在运行示例代码之前(源代码 + 示例登陆帐号) 4.         jqGrid和AJAX 5.         GridSettings 6.  ...

  8. 一篇UI规范文件

    一篇UI规范文件 这是一个UI模板规范,在做B/S版应用程序时比较适用,其实这样的东西算不上什么正规的规范,只是为了适应我们现在面对的开发环境和组织流程做的一些权宜的努力,和解决了一些与程序沟通和接口 ...

  9. datatables增删改查的实现

    学习可参考:http://www.guoxk.com/node/jquery-datatables http://yuemeiqing2008-163-com.iteye.com/blog/20069 ...

随机推荐

  1. EasyUI 列表展示及基本格式

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  2. 根据数组下标在MongoDB中修改数组元素

    如下图这样的数据: 即文档中某个字段是一个数组,而每个数组元素又是一个对象,现在需求是对每个对象中的content字段值作情感分析后,把情感分析得到的结果增加到这个对象中去. 如上图中第1个元素,修改 ...

  3. Access to the path 'C:\inetpub\wwwroot\mysite\images\savehere' is denied.

    访问路径被拒绝 我解决了这个设置: IIS>应用程序池> [您的站点]>高级设置...>标识>内置帐户> LocalSystem

  4. Windows phone 自定义用户控件(UserControl)——ColorPicker

    编码前 学习Windows phone自定义用户控件,在<WPF编程宝典>学习的小例子.并根据windows phone稍微的不同,做了点修改.ColorPicker(颜色拾取器):拥有三 ...

  5. SVN版本冲突问题

    --------------------siwuxie095 SVN 版本冲突问题 如:Jack 和 Mary 从仓库中将项目下载到本地,然后 Jack 修改了 项目中的一个文件,并上传到仓库中,之后 ...

  6. iOS 网络请求中的空类型字符串转换

    创建一个工具类,   .h: #import <Foundation/Foundation.h> @interface MySetNullWithStrTool : NSObject +( ...

  7. c++ stl常用

    #include<iostream>#include<string>#include<vector>#include<list>#include< ...

  8. 300最长上升子序列 · Longest Increasing Subsequence

    [抄题]: 往上走台阶 最长上升子序列问题是在一个无序的给定序列中找到一个尽可能长的由低到高排列的子序列,这种子序列不一定是连续的或者唯一的. 样例 给出 [5,4,1,2,3],LIS 是 [1,2 ...

  9. SQL2000清除SQL日志

    1.打开查询分析器,输入命令DUMP TRANSACTION 数据库名 WITH NO_LOG2.再打开企业管理器--右键你要压缩的数据库--所有任务--收缩数据库--收缩文件--选择日志文件--在收 ...

  10. [leetcode]257. Binary Tree Paths二叉树路径

    Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example ...