Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Typography

The writing-mode property

Reference for the CSS writing-mode property: horizontal-tb, vertical-rl, vertical-lr and the sideways values, with live examples and logical-property notes.

The writing-mode property sets whether lines of text run horizontally or vertically, and in which direction new lines (blocks) are stacked. Horizontal text is the default. Vertical modes are used for East Asian languages such as Japanese, Chinese and Mongolian, but also for design effects like a rotated label along the side of a card.

Changing the mode swaps the meaning of the two layout axes. In a vertical mode, the inline direction runs top to bottom, and the block direction runs horizontally. That is why modern CSS uses logical properties such as inline-size and margin-block-start: they adapt automatically.

CSS
.side-label {
  writing-mode: vertical-rl;
}

Try it

Three writing modes

In the two vertical boxes, the Latin letters are rotated a quarter turn clockwise and the lines start at the top. In vertical-rl the first line is at the right and the next lines go to the left; in vertical-lr they go to the right.

Syntax

CSS
writing-mode: horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr;
Initial value horizontal-tb
Applies to all elements except table row groups, table column groups, table rows, table columns, ruby base containers and ruby annotation containers
Inherited yes
Animatable no
Computed value as specified

Values

Value Description
horizontal-tb Lines run horizontally; blocks stack top to bottom. Default.
vertical-rl Lines run vertically; blocks stack from right to left. The standard mode for Japanese and Chinese vertical text.
vertical-lr Lines run vertically; blocks stack from left to right. Used for Mongolian.
sideways-rl Like vertical-rl, but all glyphs are set sideways (rotated), like a rotated horizontal line. Newer; check a compatibility table.
sideways-lr Sideways text where lines read from bottom to top. Newer; check a compatibility table.

Usage notes

  • Latin text in vertical modes. Characters from scripts without vertical forms are rotated sideways by default. text-orientation can set them upright instead (text-orientation: upright), which suits short code-like labels.
  • Width and height swap meaning for flow. In vertical modes, inline-size is the physical height. Setting height on the container, as in the demo, is what limits the line length.
  • Use logical properties. margin-inline, padding-block, inline-size and friends follow the writing mode; margin-left does not. See logical properties.
  • Rotated labels. For a simple sideways label, writing-mode: vertical-rl plus transform: rotate(180deg) makes it read bottom to top. sideways-lr does this without a transform where supported.
  • Flex and grid. The main axis of a flex row follows the inline direction, so a row in a vertical mode runs downward.
  • Changing it on the root. Setting it on html changes the whole page and also the direction of scrolling; test thoroughly.
  • Readability. Do not use vertical text for long English passages. It is slow to read.

Browser support

horizontal-tb, vertical-rl and vertical-lr are supported in all current browsers. The sideways-* values are newer and not available everywhere, so check a compatibility table.