XML technologies / CSS / CSS Cookbook / Tables / Removing gaps between table cells

(Excerpt from “CSS Kochbuch” by Christopher Schmitt)

Problem

You want to remove the gaps between individual cells.

Solution

Set the property border-collapse to the value collapse:

#shoppingcartTable {
 border-collapse: collapse;
 width: 100%;
 border: 1px solid #666;
}
#shoppingcartTable th {
 background: #888 url(th_bkgd.jpg) repeat-x;
 font: italic 1.5em Georgia, "Times New Roman", Times, serif;
 padding: .5em 0 .5em 7px;
 text-align: left;
 border-top: 1px solid #666;
 border-bottom: 1px solid #666;
 text-shadow: #ccc -2px 2px -2px;
}

Discussion

Using the value collapse for the property border-collapse removes the gaps between table cells. If you now define cell borders, you get a line spanning the entire row or column.

See also

See the recipe Setting cell borders and padding for a detailed discussion of the collapsed border model.

  

 

 

 

back to top