w:tcBorders (Table Cell Borders)
Defines the border style for each edge (top, bottom, left, right, diagonal) of an individual table cell.
Parent elements
Description
w:tcBorders specifies the border settings for the individual sides and diagonals of a single table cell. It is defined in ECMA-376 Part 1 §17.4.67.
Cell-level borders in w:tcBorders override table-level defaults set in w:tblBorders. Each border edge (w:top, w:bottom, w:left, w:right) can have independent styling, and diagonal borders (w:tl2br, w:tr2bl) add visual emphasis. Using w:val="nil" completely suppresses an inherited border.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
| (none) | — | — | All borders are specified via child elements: w:top, w:left, w:bottom, w:right, w:insideH, w:insideV, w:tl2br, w:tr2bl. |
Each border child element supports the same attributes as described in w:tblBorders.
Examples
<w:tcPr>
<w:tcBorders>
<w:top w:val="double" w:sz="4" w:space="0" w:color="000000"/>
<w:bottom w:val="nil"/>
</w:tcBorders>
</w:tcPr>
new TableCellBorders(
new TopBorder { Val = BorderValues.Double, Size = 4, Space = 0, Color = "000000" },
new BottomBorder { Val = BorderValues.Nil });
Notes
- Precedence: Cell borders override table borders and table styles.
- Diagonal Borders:
w:tl2brandw:tr2blare only valid inw:tcBorders, not in table-levelw:tblBorders. - Size in Eighths: Border
w:szis in eighths-of-a-point; use sz=”8” for 1 point. - Space Attribute:
w:spacecontrols distance in points between border and cell content. - Nil Override: Use
w:val="nil"to force removal of borders inherited from table or style. - Alternating Rows: Combine cell borders with
w:shdfor visually distinct row patterns. - Compatibility: All border styles render consistently in Office 2007+.