Writing modes & logical
The properties that set which way text runs and lines stack, and the flow-relative (logical) versions of sizes, margins, padding, insets and overflow, which follow the writing mode instead of the screen's top, right, bottom and left. The physical versions are under Box model and Positioning, floats & columns; the logical borders and corner radii (border-inline-start, border-start-start-radius and so on) are under Borders, corners & outlines.
Writing mode & direction
writing-mode
Sets whether lines of text run horizontally or vertically, and which way successive lines (and blocks) stack. It defines the block axis and the inline axis that every logical property on this page is measured along.
| Syntax | horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr |
|---|---|
| Initial | 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 |
| Animation | Not animatable |
| Support | Chrome 48 · Firefox 41 · Safari 10.1 |
| Spec | css-writing-modes-4 |
| Value | Effect |
|---|---|
horizontal-tb | Horizontal lines, stacked top to bottom. The default for Latin, Arabic, Hebrew and most other scripts. |
vertical-rl | Vertical lines, stacked right to left. Used for traditional Chinese, Japanese and Korean layout. |
vertical-lr | Vertical lines, stacked left to right. Used for Mongolian. |
sideways-rl | Vertical lines stacked right to left, with all glyphs turned 90° clockwise, as if horizontal text were rotated. |
sideways-lr | Vertical lines stacked left to right, with all glyphs turned 90° anticlockwise, so the text reads bottom to top. Useful for spine labels and table headers. |
The two sideways-* values arrived later: Chrome 132 · Firefox 43 · Safari 18.4.
writing-mode: vertical-rl;
direction
The base direction of text in the inline axis: left to right or right to left. It decides where inline-start and inline-end fall, the order of table columns, and which side text aligned to start sits on. In HTML, set it with the dir attribute rather than CSS, because direction belongs to the content, not its styling.
| Syntax | ltr | rtl |
|---|---|
| Initial | ltr |
| Applies to | All elements |
| Inherited | Yes |
| Animation | Not animatable |
| Support | Chrome 2 · Firefox 1 · Safari 1 |
| Spec | css-writing-modes-4 |
unicode-bidi
Controls how an element's text takes part in the Unicode bidirectional algorithm when left-to-right and right-to-left text are mixed. Like direction, it is usually better set from markup (dir, <bdi>, <bdo>).
| Syntax | normal | embed | isolate | bidi-override | isolate-override | plaintext |
|---|---|
| Initial | normal |
| Applies to | All elements, but see prose |
| Inherited | No |
| Animation | Not animatable |
| Support | Chrome 2 · Firefox 1 · Safari 1.3 |
| Spec | css-writing-modes-4 |
| Value | Effect |
|---|---|
normal | No extra embedding; the element's text is reordered along with its surroundings. |
embed | Opens a new embedding level in the direction given by direction. |
isolate | Treats the element's content as a separate run, so it cannot reorder the text around it. This is what <bdi> does. |
bidi-override | Lays characters out strictly in the order given by direction, ignoring their own directionality. This is what <bdo> does. |
isolate-override | Both: isolates the content and overrides its order. |
plaintext | Isolates the content and works out its direction from its own text, paragraph by paragraph, ignoring direction. |
isolate, isolate-override and plaintext arrived later: Chrome 48 · Firefox 50 · Safari 11.
text-orientation
Sets how characters are turned in vertical writing modes. It has no effect in horizontal-tb.
| Syntax | mixed | upright | sideways |
|---|---|
| Initial | mixed |
| Applies to | All elements except table row groups, rows, column groups and columns; and text |
| Inherited | Yes |
| Animation | Not animatable |
| Support | Chrome 48 · Firefox 41 · Safari 14 |
| Spec | css-writing-modes-4 |
| Value | Effect |
|---|---|
mixed | Characters from horizontal scripts such as Latin are turned 90° clockwise; characters from vertical scripts such as Chinese and Japanese stay upright. |
upright | Every character stays upright, stacked one above the next. |
sideways | Every character is turned 90° clockwise, as if a horizontal line were rotated. |
text-combine-upright
In vertical text, squeezes a short run of characters, such as the two digits of a date, into the space of a single upright character so they read horizontally. Japanese typesetting calls this tate-chū-yoko.
| Syntax | none | all | [ digits <integer [2,4]>? ] |
|---|---|
| Initial | none |
| Applies to | Inline boxes and text |
| Inherited | Yes |
| Animation | Not animatable |
| Support | Chrome 48 · Firefox 48 · Safari 15.4 |
| Spec | css-writing-modes-4 |
.tcy { text-combine-upright: all; }
glyph-orientation-vertical Deprecated
A legacy SVG property for turning glyphs in vertical text. It has no behaviour of its own: its values map onto text-orientation (auto to mixed, 0deg to upright, 90deg to sideways). Use text-orientation instead.
| Syntax | auto | 0deg | 90deg | 0 | 90 |
|---|---|
| Initial | None of its own; it sets text-orientation |
| Applies to | As for text-orientation |
| Inherited | As for text-orientation |
| Support | Chrome no · Firefox no · Safari 4 |
| Spec | css-writing-modes-4 |
Logical sizes
Logical properties name sides and axes by the flow of text. The inline axis is the direction text runs along a line; the block axis is the direction lines and blocks stack. Start and end are the two ends of each axis. Which physical side each one means depends on writing-mode and direction:
| Logical | horizontal-tb, ltr | horizontal-tb, rtl | vertical-rl, ltr |
|---|---|---|---|
inline-start | left | right | top |
inline-end | right | left | bottom |
block-start | top | top | right |
block-end | bottom | bottom | left |
inline-size | width | width | height |
block-size | height | height | width |
So in ordinary left-to-right English, margin-inline-start is margin-left and padding-block-end is padding-bottom. The same stylesheet then works unchanged for right-to-left and vertical text.
inline-size, block-size
The preferred size of the box along the inline axis and the block axis. In horizontal writing modes they are width and height; in vertical ones, the other way round.
| Syntax | auto | <box-size> | <anchor-size()> |
|---|---|
| Initial | auto |
| Applies to | All elements except non-replaced inline boxes |
| Inherited | No |
| Percentages | Relative to the width or height of the containing block, whichever lies in the same axis |
| Animation | By computed value type, recursing into fit-content() |
| Support | Chrome 57 · Firefox 41 · Safari 12.1 |
| Spec | css-sizing-3 |
min-inline-size, min-block-size
A lower limit on the box's size along the inline or block axis: the logical forms of min-width and min-height.
| Syntax | auto | <box-size> | <anchor-size()> |
|---|---|
| Initial | auto |
| Applies to | All elements that accept width or height |
| Inherited | No |
| Percentages | Relative to the width or height of the containing block, whichever lies in the same axis |
| Animation | By computed value, recursing into fit-content() |
| Support | Chrome 57 · Firefox 41 · Safari 12.1 |
| Spec | css-sizing-3 |
max-inline-size, max-block-size
An upper limit on the box's size along the inline or block axis: the logical forms of max-width and max-height.
| Syntax | none | <box-size> | <anchor-size()> |
|---|---|
| Initial | none |
| Applies to | All elements that accept width or height |
| Inherited | No |
| Percentages | Relative to the width or height of the containing block, whichever lies in the same axis |
| Animation | By computed value, recursing into fit-content() |
| Support | Chrome 57 · Firefox 41 · Safari 12.1 |
| Spec | css-sizing-3 |
max-inline-size: 65ch;
Logical margins
margin-block, margin-inline
Shorthands for the two margins in one axis. One value sets both the start and end margin; two values set start then end.
| Syntax | <'margin-top'>{1,2} |
|---|---|
| Initial | See individual properties |
| Applies to | See individual properties |
| Inherited | See individual properties |
| Percentages | See individual properties |
| Animation | See individual properties |
| Support | Chrome 87 · Firefox 66 · Safari 14.1 |
| Spec | css-logical-1 |
margin-inline: auto;
margin-block-start, margin-block-end, margin-inline-start, margin-inline-end
The margin on one flow-relative side. Each one maps to a physical margin according to the writing mode and direction, as in the table above.
| Syntax | <'margin-top'> |
|---|---|
| Initial | 0 |
| Applies to | Same as margin-top |
| Inherited | No |
| Percentages | As for the corresponding physical property |
| Animation | By computed value type |
| Support | Chrome 69 · Firefox 41 · Safari 12.1 |
| Spec | css-logical-1 |
Logical padding
padding-block, padding-inline
Shorthands for the two paddings in one axis. One value sets both the start and end padding; two values set start then end.
| Syntax | <'padding-top'>{1,2} |
|---|---|
| Initial | See individual properties |
| Applies to | See individual properties |
| Inherited | See individual properties |
| Percentages | See individual properties |
| Animation | See individual properties |
| Support | Chrome 87 · Firefox 66 · Safari 14.1 |
| Spec | css-logical-1 |
padding-block: 0.5rem;
padding-inline: 1rem;
padding-block-start, padding-block-end, padding-inline-start, padding-inline-end
The padding on one flow-relative side. Each one maps to a physical padding according to the writing mode and direction.
| Syntax | <'padding-top'> |
|---|---|
| Initial | 0 |
| Applies to | Same as padding-top |
| Inherited | No |
| Percentages | As for the corresponding physical property |
| Animation | By computed value type |
| Support | Chrome 69 · Firefox 41 · Safari 12.1 |
| Spec | css-logical-1 |
Logical insets
inset-block, inset-inline
Shorthands for the two insets of a positioned box in one axis. One value sets both start and end; two values set start then end. The physical top, right, bottom, left and inset are under Positioning, floats & columns.
| Syntax | <'top'>{1,2} |
|---|---|
| Initial | auto |
| Applies to | Positioned elements |
| Inherited | No |
| Percentages | See individual properties |
| Animation | By computed value type |
| Support | Chrome 87 · Firefox 63 · Safari 14.1 |
| Spec | css-position-3 |
inset-block-start, inset-block-end, inset-inline-start, inset-inline-end
The distance of a positioned box's edge from the matching edge of its containing block, on one flow-relative side.
| Syntax | auto | <length-percentage> |
|---|---|
| Initial | auto |
| Applies to | Positioned elements |
| Inherited | No |
| Percentages | Refer to the size of the containing block in the same axis |
| Animation | By computed value type |
| Support | Chrome 87 · Firefox 63 · Safari 14.1 |
| Spec | css-position-3 |
position: absolute;
inset-block-start: 0;
inset-inline-end: 0;
Logical overflow
overflow-block, overflow-inline
Overflow handling along the block axis or the inline axis: the logical forms of overflow-y and overflow-x in horizontal writing modes. The values mean the same as for overflow.
| Syntax | visible | hidden | clip | scroll | auto |
|---|---|
| Initial | visible |
| Applies to | Block containers, flex containers, grid containers and table grid boxes |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 135 · Firefox 69 · Safari 26 |
| Spec | css-overflow-3 |