w:tblPr (Table Properties)

Container for all formatting properties applied to an entire table.

Description

w:tblPr is the table properties container, grouping all table-level formatting properties. It is defined in ECMA-376 Part 1 §17.4.60.

w:tblPr is always the first child of w:tbl. It contains child elements such as w:tblStyle (style reference), w:tblW (width), w:tblBorders (table borders), w:tblCellMar (default cell margins), w:tblLook (conditional format application flags), and many others. Properties set at the table level apply to all cells unless overridden by cell-level properties (w:tcPr).

Table properties control the overall appearance and behavior of the table, including alignment, indentation, spacing, borders, shading, and column properties.

Attributes

Attribute Type Possible Values Description
(none) — — All table properties are expressed exclusively via child elements.

Common Child Elements

Child Purpose Example
w:tblStyle Applies a named table style <w:tblStyle w:val="TableGrid"/>
w:tblW Table width (auto, fixed, percentage) <w:tblW w:w="9638" w:type="dxa"/> (6.7 inches)
w:tblJc Table alignment (left/center/right) <w:tblJc w:val="center"/>
w:tblInd Left indent from margin <w:tblInd w:w="720" w:type="dxa"/> (0.5 inches)
w:tblBorders Outer borders for table <w:tblBorders><w:top .../></w:tblBorders>
w:tblCellMar Default cell margins (top/left/right/bottom) <w:tblCellMar><w:top .../></w:tblCellMar>
w:tblLook Conditional formatting (first row, last row, banded) <w:tblLook w:val="0411"/> (first row + banded rows)
w:tblCellSpacing Space between cells <w:tblCellSpacing w:w="0" w:type="dxa"/>
w:tblAutofit Autofit behavior <w:autofit w:type="autoToWindow"/>

Examples

Simple styled table (full width)

<w:tblPr>
  <w:tblStyle w:val="TableGrid"/>
  <w:tblW w:w="5000" w:type="pct"/>
  <w:tblLook w:val="0411"/>
</w:tblPr>

Centered table with fixed width and borders

<w:tblPr>
  <w:tblStyle w:val="TableNormal"/>
  <w:tblW w:w="9638" w:type="dxa"/>
  <w:tblJc w:val="center"/>
  <w:tblInd w:w="0" w:type="dxa"/>
  <w:tblBorders>
    <w:top w:val="single" w:sz="12" w:space="0" w:color="000000"/>
    <w:left w:val="single" w:sz="12" w:space="0" w:color="000000"/>
    <w:bottom w:val="single" w:sz="12" w:space="0" w:color="000000"/>
    <w:right w:val="single" w:sz="12" w:space="0" w:color="000000"/>
    <w:insideH w:val="single" w:sz="12" w:space="0" w:color="000000"/>
    <w:insideV w:val="single" w:sz="12" w:space="0" w:color="000000"/>
  </w:tblBorders>
  <w:tblCellMar>
    <w:top w:w="80" w:type="dxa"/>
    <w:left w:w="80" w:type="dxa"/>
    <w:bottom w:w="80" w:type="dxa"/>
    <w:right w:w="80" w:type="dxa"/>
  </w:tblCellMar>
</w:tblPr>

Indented table with cell spacing

<w:tblPr>
  <w:tblStyle w:val="TableGrid"/>
  <w:tblW w:w="8000" w:type="dxa"/>
  <w:tblInd w:w="720" w:type="dxa"/>
  <w:tblCellSpacing w:w="60" w:type="dxa"/>
  <w:tblLook w:val="0411"/>
</w:tblPr>

Width Measurement Reference

Type Value Example Display
Twips (dxa) 1440 twips = 1 inch <w:tblW w:w="5040" w:type="dxa"/> 3.5 inches
Percentage (pct) 5000 = 50%, 10000 = 100% <w:tblW w:w="5000" w:type="pct"/> 50% of page width
Auto 0 <w:tblW w:w="0" w:type="auto"/> Auto-width (default)

tblLook Values (Conditional Formatting)

Value Description Use Case
0411 First row + banded rows Typical styled table (header row + alternating row colors)
1600 Last row + last column Emphasis on totals/edges
0000 No special formatting Plain table without style variations
0400 First row only Simple header emphasis
1000 Last row only Totals row

All Child Elements (in order)

Child Required Multiple Purpose
w:tblStyle No No (0-1) Reference to named table style from styles.xml
w:tblPrChange No No (0-1) Revision tracking for table properties
w:tblW No No (0-1) Table width (auto, fixed twips, percentage)
w:tblInd No No (0-1) Left indent from margin
w:tblBorders No No (0-1) Table border styling (outer and inner)
w:tblCellMar No No (0-1) Default cell margins/padding for all cells
w:tblLook No No (0-1) Conditional formatting flags (first row, last row, banding)
w:tblDescription No No (0-1) Accessible table description (for screen readers)
w:tblTitle No No (0-1) Table title/caption
w:tblJc No No (0-1) Table alignment (left/center/right)
w:tblCellSpacing No No (0-1) Space between cells (cellspacing in HTML)
w:tblAutofit No No (0-1) Autofit behavior (auto/fixed/window)
w:tblPrEx No No (0-1) Exception properties for nested tables

Alignment Values

Value Behavior
left Table aligns to left margin
center Table centers on page
right Table aligns to right margin

Autofit Modes

Mode Behavior
autoToWindow Columns expand/contract to fit window width
autoToContent Columns adjust to fit cell content
fixed Column widths fixed; no autofit

Notes

  • Child element order: ECMA-376 specifies strict ordering of w:tblPr children; the OpenXml SDK enforces this automatically.
  • Style inheritance: Properties applied via w:tblStyle are inherited; direct properties in w:tblPr override style properties.
  • Cell overrides: Cell-level properties (w:tcPr) always override table-level properties; row-level properties also override table-level.
  • Width types: Percentage is relative to page width; twips (dxa) are absolute; auto-width adapts to content and container.
  • Measurement units: Twips = 1/20th point; 1 inch = 1440 twips, 1 cm ≈ 567 twips.
  • Default cell margins: Set via w:tblCellMar at table level; individual cells can override via w:tcMar for asymmetric padding.
  • Performance: Tables with many borders, complex properties, or excessive merging can impact rendering performance.
  • Accessibility: Use w:tblDescription and w:tblTitle for semantic table markup; helps screen readers understand table purpose.
  • Nested Tables: Nested tables inherit nothing from parent table; use w:tblPrEx for exception properties.
  • Spacing vs. Margins: w:tblCellSpacing is the gap between cells (like HTML cellspacing); w:tblCellMar is padding inside cells.