w:tblCellSpacing (Table Cell Spacing)
Specifies the spacing between cells in a table, or between the table border and the outermost cells, when the table uses separated borders.
Description
w:tblCellSpacing defines the gap between adjacent cells (and between cells and the outer table border) when the table uses the separated borders model. This is analogous to the CSS border-spacing property.
It is defined in ECMA-376 Part 1 §17.4.47.
When placed in w:tblPr, it sets the default cell spacing for all rows. When placed in w:trPr, it overrides that default for the individual row.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:w |
xsd:integer |
Measurement value (see w:type) |
Amount of cell spacing. |
w:type |
ST_TblWidth |
dxa, nil |
Unit for w:w. dxa = twips; nil = no spacing. |
Examples
<!-- 72 twips (0.05 inch) spacing between cells -->
<w:tblPr>
<w:tblCellSpacing w:w="72" w:type="dxa"/>
</w:tblPr>
using DocumentFormat.OpenXml.Wordprocessing;
var tblPr = new TableProperties(
new TableCellSpacing { Width = "72", Type = TableWidthUnitValues.Dxa }
);
Notes
- Cell spacing is only meaningful with separated borders (not collapsed). With collapsed borders (
w:tblBordersusing a single border), spacing is visually ignored. - Row-level
w:tblCellSpacinginw:trProverrides the table-level value for that row. - Setting
w:type="nil"removes cell spacing, making borders collapse.