w:textDirection (Text Flow Direction)
Specifies the direction of text flow within a table cell or section, supporting horizontal, vertical, and bidirectional layouts.
Description
w:textDirection controls the direction in which text flows within a table cell or section. It enables vertical text orientations used in East Asian typography and other specialized layouts.
It is defined in:
- §17.4.81 for the table cell context (
w:tcPr). - §17.6.28 for the section context (
w:sectPr).
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:val |
ST_TextDirection |
See below | Text flow direction. |
Values
| Value | Description |
|---|---|
lr |
Left-to-right, top-to-bottom (default). |
rl |
Right-to-left, top-to-bottom. |
tbRl |
Top-to-bottom, right-to-left (vertical CJK). |
btLr |
Bottom-to-top, left-to-right (rotated 90° CCW). |
lrV |
Left-to-right, top-to-bottom with vertical characters. |
rlV |
Right-to-left, top-to-bottom with vertical characters. |
tbLrV |
Top-to-bottom, left-to-right with vertical characters. |
Examples
<!-- Vertical text in a table cell (common for row headers) -->
<w:tc>
<w:tcPr>
<w:textDirection w:val="tbRl"/>
<w:vAlign w:val="center"/>
</w:tcPr>
<w:p><w:r><w:t>Vertical header</w:t></w:r></w:p>
</w:tc>
using DocumentFormat.OpenXml.Wordprocessing;
var tcPr = new TableCellProperties(
new TextDirection { Val = TextDirectionValues.TopToBottomRightToLeft },
new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center }
);
Notes
tbRl(top-to-bottom, right-to-left) is the most common vertical text direction for CJK column headers.- When
w:textDirectionis applied to a cell, the cell’s width and height roles are effectively swapped — width becomes the line length and height becomes the flow length. - Support for all values varies across renderers;
lr,rl, andtbRlare the most widely supported.