標籤:blog http os io 使用 strong ar for 2014
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