CSS writing-mode Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The writing-mode property sets whether lines of text are laid out horizontally or vertically, and which way block lines stack. It defines the block flow direction and how inline content flows inside a block.

The property is inherited. The initial value is horizontal-tb. For a whole document, set it on the root (html). Pair with direction and text-orientation for finer control.

Baseline widely available.

Core values (horizontal-tb, vertical-rl, vertical-lr) are widely supported. sideways-rl / sideways-lr have limited support. Old SVG keywords like lr, tb, and rl are deprecated for CSS — use the modern keywords instead.

CSS Syntax

syntax.css
writing-mode: horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr | initial | inherit;

Example: writing-mode: vertical-rl;. Use one keyword at a time.

Property Values

ValueDescriptionTry it
horizontal-tbDefault. Horizontal lines; next line belowTry it
vertical-rlVertical lines; next line to the left (common for CJK)Try it
vertical-lrVertical lines; next line to the rightTry it
sideways-rlLimited support. Vertical flow; glyphs sideways toward the rightTry it
sideways-lrLimited support. Vertical flow; glyphs sideways toward the leftLimited
initialResets to the default value, horizontal-tbTry it
inheritInherits this property from the parent elementTry it

How to Use writing-mode

Pick a flow for the block, then check how logical properties and text orientation behave.

  1. Start with horizontal-tb for most Latin layouts.
  2. Use vertical-rl or vertical-lr for vertical text (headings, CJK, side labels).
  3. For a full page, set writing-mode on html (or the root).
  4. Combine with text-orientation when vertical Latin letters need upright or sideways glyphs.
PieceRequired?Role
KeywordYesChooses horizontal vs vertical block flow
directionOptionalLTR vs RTL within the writing mode
text-orientationOptionalHow glyphs sit in vertical modes
Logical sizesHelpfulblock-size / inline-size follow the mode

Live Preview

Change writing-mode and watch how the sample text flows and stacks.

sideways-rl may look like a vertical mode if your browser does not support it yet.

Sample

Example text

我家没有电脑。

writing-mode: horizontal-tb

CSS Examples

Each snippet focuses on writing-mode with a short sample so the flow is easy to see. Use Try It Yourself for a live editor.

Example 1 — horizontal-tb

Default layout: lines run horizontally; the next line is below.

CSS
<style>
  div {
    writing-mode: horizontal-tb;
    border: 1px solid #334155;
    padding: 8px;
  }
</style>

<div>
  <p>Example text</p>
  <p>Next line below</p>
</div>
Try It Yourself

How It Works

  1. Set horizontal-tb. This is the initial value for most Western layouts.
  2. Inline axis is horizontal. Characters flow left-to-right (or right-to-left with direction).
  3. Block axis is vertical. The next paragraph or line box stacks below.
  4. Baseline for comparison. Change to a vertical mode in the next examples to see the difference.

Example 2 — vertical-rl

Vertical lines with the next line to the left — common for Japanese-style vertical text.

CSS
<style>
  div {
    writing-mode: vertical-rl;
    height: 160px;
    border: 1px solid #334155;
    padding: 8px;
  }
</style>

<div>
  <p>Example text</p>
  <p lang="zh">我家没有电脑。</p>
</div>
Try It Yourself

How It Works

  1. Set vertical-rl. Inline content runs top to bottom in a vertical line.
  2. Give a height. Vertical modes need vertical room so lines can stack sideways.
  3. Next line goes left. The second paragraph appears to the left of the first.
  4. Useful for CJK and side labels. Latin letters may look rotated; tune with text-orientation if needed.

Example 3 — vertical-lr

Vertical lines with the next line to the right.

CSS
<style>
  div {
    writing-mode: vertical-lr;
    height: 160px;
    border: 1px solid #334155;
    padding: 8px;
  }
</style>

<div>
  <p>Example text</p>
  <p>Next line right</p>
</div>
Try It Yourself

How It Works

  1. Set vertical-lr. Still a vertical inline axis.
  2. Next line goes right. Compared with Example 2, the block progression flips.
  3. Same height tip. A fixed height makes the sideways stack easy to see.
  4. Pick by language need. Choose rl or lr to match the script’s traditional line order.

Edge Cases & Pitfalls

Most surprises come from limited sideways support or mixing physical vs logical CSS.

deprecated

Avoid old SVG keywords in CSS

lr, rl, tb, lr-tb, tb-rl, and similar are deprecated for CSS (SVG1 only). Use horizontal-tb, vertical-rl, or vertical-lr.

limited

sideways-* support varies

sideways-rl and sideways-lr are not as widely available as the core three values. Provide a vertical fallback when they matter.

logical

Physical edges change meaning

margin-top is still physical top. Prefer block-size / inline-size and logical margins when layouts must follow the writing mode.

height

Vertical demos need vertical space

Without a height (or enough content), vertical modes can look cramped. Set a height when studying line stacking.

orientation

Latin in vertical modes

Latin glyphs may rotate. Use text-orientation to keep them upright or sideways as needed.

Browser Support

writing-mode is a browser CSS property for text layout. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

writing-mode

horizontal-tb, vertical-rl, and vertical-lr are widely supported. sideways-rl and sideways-lr have limited support. Deprecated SVG keywords should not be used in modern CSS.

97% Core values
Google Chrome Supported
Full support (core)
Mozilla Firefox Supported
Full support (core)
Apple Safari Supported
Full support (core)
Microsoft Edge Supported
Full support (core)
Opera Supported
Full support (core)
Samsung Internet Supported
Full support (core)
Internet Explorer Partial
Older prefixes / limited
writing-mode Baseline · Core values

Bottom line: Safe to use for horizontal and vertical layouts. Treat sideways values as progressive enhancement. This is not a JavaScript runtime API.

Key Takeaways

  • Role: choose horizontal or vertical text flow and how lines stack.
  • Initial: horizontal-tb. Inherited. Set on html for a whole page.
  • vertical-rl vs vertical-lr: next line left vs right.
  • Skip deprecated SVG names; treat sideways-* as limited.

One line: writing-mode flips the map of “block” and “inline” — start with horizontal-tb, then go vertical when the script needs it.

Frequently Asked Questions

It sets whether lines of text are laid out horizontally or vertically, and the direction in which block lines stack.
The initial value is horizontal-tb. Text flows horizontally, and the next line is placed below.
Both stack text in vertical lines. vertical-rl places the next line to the left (common for Japanese). vertical-lr places the next line to the right.
Set it on the root element (html for HTML documents) so the entire document uses that mode.
Support is limited compared with horizontal-tb, vertical-rl, and vertical-lr. Treat sideways values as progressive enhancement.
Yes. It applies to most elements (not table row/column groups) and is inherited. It is a browser CSS property, not a Node.js feature.

Next: z-index

Learn how to control stacking order of positioned elements.

z-index tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful