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.

Syntaxhorizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr
Initialhorizontal-tb
Applies toAll elements except table row groups, table column groups, table rows, table columns, ruby base containers and ruby annotation containers
InheritedYes
AnimationNot animatable
SupportChrome 48 · Firefox 41 · Safari 10.1
Speccss-writing-modes-4
ValueEffect
horizontal-tbHorizontal lines, stacked top to bottom. The default for Latin, Arabic, Hebrew and most other scripts.
vertical-rlVertical lines, stacked right to left. Used for traditional Chinese, Japanese and Korean layout.
vertical-lrVertical lines, stacked left to right. Used for Mongolian.
sideways-rlVertical lines stacked right to left, with all glyphs turned 90° clockwise, as if horizontal text were rotated.
sideways-lrVertical 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;
Vertical text, with lines stacking from right to left.

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.

Syntaxltr | rtl
Initialltr
Applies toAll elements
InheritedYes
AnimationNot animatable
SupportChrome 2 · Firefox 1 · Safari 1
Speccss-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>).

Syntaxnormal | embed | isolate | bidi-override | isolate-override | plaintext
Initialnormal
Applies toAll elements, but see prose
InheritedNo
AnimationNot animatable
SupportChrome 2 · Firefox 1 · Safari 1.3
Speccss-writing-modes-4
ValueEffect
normalNo extra embedding; the element's text is reordered along with its surroundings.
embedOpens a new embedding level in the direction given by direction.
isolateTreats the element's content as a separate run, so it cannot reorder the text around it. This is what <bdi> does.
bidi-overrideLays characters out strictly in the order given by direction, ignoring their own directionality. This is what <bdo> does.
isolate-overrideBoth: isolates the content and overrides its order.
plaintextIsolates 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.

Syntaxmixed | upright | sideways
Initialmixed
Applies toAll elements except table row groups, rows, column groups and columns; and text
InheritedYes
AnimationNot animatable
SupportChrome 48 · Firefox 41 · Safari 14
Speccss-writing-modes-4
ValueEffect
mixedCharacters from horizontal scripts such as Latin are turned 90° clockwise; characters from vertical scripts such as Chinese and Japanese stay upright.
uprightEvery character stays upright, stacked one above the next.
sidewaysEvery 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.

Syntaxnone | all | [ digits <integer [2,4]>? ]
Initialnone
Applies toInline boxes and text
InheritedYes
AnimationNot animatable
SupportChrome 48 · Firefox 48 · Safari 15.4
Speccss-writing-modes-4
.tcy { text-combine-upright: all; }
Wrap the short run in an element and combine all of its characters into one upright cell.

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.

Syntaxauto | 0deg | 90deg | 0 | 90
InitialNone of its own; it sets text-orientation
Applies toAs for text-orientation
InheritedAs for text-orientation
SupportChrome no · Firefox no · Safari 4
Speccss-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:

Logicalhorizontal-tb, ltrhorizontal-tb, rtlvertical-rl, ltr
inline-startleftrighttop
inline-endrightleftbottom
block-starttoptopright
block-endbottombottomleft
inline-sizewidthwidthheight
block-sizeheightheightwidth

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.

Syntaxauto | <box-size> | <anchor-size()>
Initialauto
Applies toAll elements except non-replaced inline boxes
InheritedNo
PercentagesRelative to the width or height of the containing block, whichever lies in the same axis
AnimationBy computed value type, recursing into fit-content()
SupportChrome 57 · Firefox 41 · Safari 12.1
Speccss-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.

Syntaxauto | <box-size> | <anchor-size()>
Initialauto
Applies toAll elements that accept width or height
InheritedNo
PercentagesRelative to the width or height of the containing block, whichever lies in the same axis
AnimationBy computed value, recursing into fit-content()
SupportChrome 57 · Firefox 41 · Safari 12.1
Speccss-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.

Syntaxnone | <box-size> | <anchor-size()>
Initialnone
Applies toAll elements that accept width or height
InheritedNo
PercentagesRelative to the width or height of the containing block, whichever lies in the same axis
AnimationBy computed value, recursing into fit-content()
SupportChrome 57 · Firefox 41 · Safari 12.1
Speccss-sizing-3
max-inline-size: 65ch;
A readable line length that still applies when the text is set vertically.

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}
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
PercentagesSee individual properties
AnimationSee individual properties
SupportChrome 87 · Firefox 66 · Safari 14.1
Speccss-logical-1
margin-inline: auto;
Centre a sized block in its container, in any writing mode.

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'>
Initial0
Applies toSame as margin-top
InheritedNo
PercentagesAs for the corresponding physical property
AnimationBy computed value type
SupportChrome 69 · Firefox 41 · Safari 12.1
Speccss-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}
InitialSee individual properties
Applies toSee individual properties
InheritedSee individual properties
PercentagesSee individual properties
AnimationSee individual properties
SupportChrome 87 · Firefox 66 · Safari 14.1
Speccss-logical-1
padding-block: 0.5rem;
padding-inline: 1rem;
Button-style padding: tighter between lines, wider along them.

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'>
Initial0
Applies toSame as padding-top
InheritedNo
PercentagesAs for the corresponding physical property
AnimationBy computed value type
SupportChrome 69 · Firefox 41 · Safari 12.1
Speccss-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}
Initialauto
Applies toPositioned elements
InheritedNo
PercentagesSee individual properties
AnimationBy computed value type
SupportChrome 87 · Firefox 63 · Safari 14.1
Speccss-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.

Syntaxauto | <length-percentage>
Initialauto
Applies toPositioned elements
InheritedNo
PercentagesRefer to the size of the containing block in the same axis
AnimationBy computed value type
SupportChrome 87 · Firefox 63 · Safari 14.1
Speccss-position-3
position: absolute;
inset-block-start: 0;
inset-inline-end: 0;
Pin a close button to the top corner at the end of the line: top right in English, top left in Arabic.

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.

Syntaxvisible | hidden | clip | scroll | auto
Initialvisible
Applies toBlock containers, flex containers, grid containers and table grid boxes
InheritedNo
AnimationDiscrete
SupportChrome 135 · Firefox 69 · Safari 26
Speccss-overflow-3