w:vAlign (Vertical Text Alignment)
Specifies the vertical alignment of content within a page (in a section) or within a table cell.
Description
w:vAlign controls vertical alignment of content in two distinct contexts:
- Section (
w:sectPr) — aligns the text block vertically on each page of the section. - Table cell (
w:tcPr) — aligns cell content vertically within the cell.
It is defined in:
- §17.6.23 for the section context.
- §17.4.84 for the table cell context.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:val |
ST_VerticalJc |
top, center, both, bottom |
Vertical alignment mode. |
Values
| Value | Description |
|---|---|
top |
Content starts at the top edge. |
center |
Content is centered vertically. |
both |
(Section only) Content is vertically justified (spread evenly between top and bottom margins). |
bottom |
Content ends at the bottom edge. |
Examples
<!-- Vertically center page content (cover page) -->
<w:sectPr>
<w:vAlign w:val="center"/>
<w:pgSz w:w="12240" w:h="15840"/>
</w:sectPr>
<!-- Vertically center content in a table cell -->
<w:tc>
<w:tcPr>
<w:vAlign w:val="center"/>
</w:tcPr>
<w:p><w:r><w:t>Centered cell</w:t></w:r></w:p>
</w:tc>
using DocumentFormat.OpenXml.Wordprocessing;
// Section vertical alignment
var sectPr = new SectionProperties(
new VerticalTextAlignmentOnPage { Val = VerticalJustificationValues.Center }
);
// Table cell vertical alignment
var tcPr = new TableCellProperties(
new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center }
);
Notes
- In the section context,
w:val="both"is equivalent to “vertical justification” and distributes paragraphs evenly between the top and bottom margins. - In the table cell context, the
bothvalue is typically not supported by most processors; usetop,center, orbottomfor cells. - The default vertical alignment for both sections and cells is
top.