concept
Table wrapper box — CSS reference
A table generates a wrapper box enclosing its grid and caption boxes. The wrapper participates in surrounding layout; table margins apply to the wrapper. The DOM table bounding rectangle can include the caption, so measure cell geometry separately when debugging the grid.
Formal Syntax & Structure
css syntaxcss
table { margin: 10px; caption-side: top; }Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>Table wrapper box</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}body{font:16px/20px sans-serif;background:white}#a{padding:0;background:transparent;margin:10px;color:black}table{border-spacing:0}td,th{padding:0}caption{padding:0}#a{width:200px}caption{height:20px}td,th{height:30px}</style><body><table id="a"><caption>Inventory</caption><tbody><tr><th scope="col" id="x">Item</th><th scope="col" id="y">Qty</th></tr><tr><td id="z">Pen</td><td>5</td></tr></tbody></table></body></html>