CSS Writing Modes Reference

writing-mode, direction, text-orientation values with block/inline axis effects.

Reference for CSS writing mode properties (writing-mode, direction, text-orientation) with each value's block and inline axis direction, and the mapping from physical to logical properties.

What does writing-mode control?

writing-mode sets the direction blocks are stacked (the block axis) and how text lines flow (the inline axis). horizontal-tb stacks blocks top-to-bottom with horizontal lines; vertical-rl and vertical-lr rotate the layout so lines run vertically and columns advance right-to-left or left-to-right.

What CSS writing modes control

Writing modes generalise CSS layout beyond left-to-right horizontal text. The writing-mode property sets which way blocks stack and lines flow, direction sets right-to-left vs left-to-right inline progression, and text-orientation rotates glyphs in vertical modes. Together they define the block axis and inline axis that logical properties follow. This reference lists every value with the axes it produces.

How it works

writing-mode establishes two axes. The block axis is the direction new lines (blocks) advance; the inline axis is the direction characters within a line advance. direction flips the inline axis for RTL scripts:

.cjk {
  writing-mode: vertical-rl;   /* lines run top→bottom, columns right→left */
  text-orientation: mixed;     /* CJK upright, Latin rotated */
}
.arabic {
  direction: rtl;              /* inline axis runs right→left */
}
/* logical property — follows the mode automatically */
.box { margin-inline-start: 1rem; }

In horizontal-tb ltr, inline-start resolves to left and block-start to top. Switch to vertical-rl and the same logical properties remap to physical edges automatically — so a single rule lays out correctly in any mode.

Tips and notes

  • Prefer logical properties (margin-inline, inset-block, border-inline-start) over physical ones for international layouts.
  • text-orientation only affects vertical writing modes; it is ignored in horizontal-tb.
  • vertical-rl is the traditional CJK default; vertical-lr advances columns left-to-right.
  • Combine writing-mode: sideways-lr with rotated table headers for compact, readable vertical labels.