w:tc is a table cell containing one or more block-level elements (paragraphs and/or nested tables). It is defined in ECMA-376 Part 1 §17.4.66.
Every w:tc must contain at least one w:p as its last child. Cell properties are specified in an optional leading w:tcPr element. Cells span multiple columns via w:gridSpan in w:tcPr, and merge vertically via w:vMerge.
Attributes
Attribute
Type
Possible Values
Description
(none)
—
—
Properties are expressed via the w:tcPr child element.
new TableCell(
new TableCellProperties(
new TableCellWidth { Width = "2500", Type = TableWidthUnitValues.Dxa }),
new Paragraph(new Run(new Text("Cell content"))));
new TableCell(
new TableCellProperties(
new TableCellWidth { Width = "5000", Type = TableWidthUnitValues.Dxa },
new GridSpan { Val = 2 },
new Shading { Fill = "E8E8E8" }),
new Paragraph(
new ParagraphProperties(new Justification { Val = JustificationValues.Center }),
new Run(new Text("Spans 2 columns"))));
new TableCell(
new TableCellProperties(
new TableCellWidth { Width = "2500", Type = TableWidthUnitValues.Dxa }),
new Paragraph(new Run(new Text("Above table:"))),
new Table(
new TableGrid(new GridColumn { Width = "1250" }, new GridColumn { Width = "1250" }),
new TableRow(
new TableCell(new Paragraph(new Run(new Text("N1")))),
new TableCell(new Paragraph(new Run(new Text("N2")))))),
new Paragraph(new Run(new Text("Below table"))));
Cell Properties Reference
Property
Purpose
Example
w:tcW
Cell width (twips, percent, or auto)
<w:tcW w:w="2500" w:type="dxa"/>
w:gridSpan
Horizontal span (merges columns)
<w:gridSpan w:val="2"/> (spans 2 grid columns)
w:vMerge
Vertical merge (spans rows)
<w:vMerge/> (start) or <w:vMerge w:val="continue"/> (continuation)
Cell occupies N grid columns; reduces cell count in row
Vertical (multi-row)
w:vMerge (start/continue)
First cell in span: <w:vMerge/>, subsequent cells: <w:vMerge w:val="continue"/>
Combined
Both gridSpan and vMerge
Cell can span both horizontally and vertically simultaneously
Notes
Mandatory final paragraph: Every w:tc must end with at least one w:p (paragraph), even if the cell contains only a table. This is a ECMA-376 requirement for spec compliance.
Cell width types: Cell width can be absolute (twips/dxa), percentage (pct), or auto; width is constrained by table width and column definitions.
Vertical merge restart: Use <w:vMerge/> (no w:val attribute) to start a vertical merge block; cells below use <w:vMerge w:val="continue"/>.
Grid Span Impact: When a cell uses w:gridSpan w:val="2", it occupies 2 logical grid columns; the next cell in the row moves to column 3 (not column 2).
Empty Cells: A cell must contain at least one <w:p> even if empty; never leave a cell with no paragraph.
Nested Tables: Tables inside cells inherit no properties from the parent table; define complete table properties for nested tables.
Text Fitting: Use w:tcFitText to automatically shrink font if text doesn’t fit; useful for fixed-size cells.
Accessibility: Ensure header cells use w:shd contrast and semantic markup; use row/column headers for table navigation.
Vertical merge content: Continuation cells in a vertical merge still must contain at least one w:p, but the paragraph is typically empty or hidden from view.
Column spanning vs. vertical merge: w:gridSpan spans horizontally across columns; w:vMerge merges cells vertically across rows; they are independent operations.
Cell properties override: Cell-level properties in w:tcPr always override table-level properties in w:tblPr; this allows fine-grained control per cell.
Nested table content: When a cell contains a nested table, the table structure is complete (including w:tblGrid, w:tblPr, w:tr); the paragraph requirement still applies.
Cell margins: Cell padding/margins are controlled via w:tblPr/w:tblCellMar (table-level default) or w:tcPr/w:tcMar (cell-level override).
Borders and shading: Individual cell borders and background colors override table-level borders; this allows striped or highlighted rows/columns.
Accessibility: Ensure cells contain meaningful content and are structured logically; avoid completely empty cells in data tables as they confuse screen readers.
Privacy Notice
This site stores your theme preference and this acknowledgement in localStorage — no cookies, no tracking. When you use the contact form, your message is sent via Formspree (USA) to reach us.