CSS writing-mode Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Typography

What You’ll Learn

The writing-mode property controls text direction and line stacking — essential for vertical East Asian layouts and creative design patterns.

01

Text flow

Horizontal vs vertical.

02

Syntax

Keyword values.

03

horizontal-tb

Default value.

04

vertical-rl

Right-to-left lines.

05

vertical-lr

Left-to-right lines.

06

CJK layouts

Japanese & Chinese.

Introduction

The writing-mode property in CSS is used to define the direction and orientation of text. This property is particularly useful for languages that are written vertically, such as Japanese and Chinese, as well as for creating unique layouts where text direction plays a key role.

By using the writing-mode property, you can control whether text is laid out horizontally or vertically and the direction in which lines are stacked.

Definition and Usage

Apply writing-mode on blocks of text, labels, or layout containers when you need vertical flow or when logical properties should follow a rotated writing axis. Pair it with text-orientation for fine control over character rotation inside vertical lines.

💡
Beginner Tip

Most Western websites use the default horizontal-tb. For Japanese vertical text, start with writing-mode: vertical-rl; and add text-orientation: upright; when every character should stay upright.

📝 Syntax

The syntax for the writing-mode property is simple and consists of specifying one of the predefined values.

syntax.css
element {
  writing-mode: horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr;
}

Basic Example

writing-mode.css
p {
  writing-mode: vertical-rl;
  width: 200px;
  height: 100px;
}

Syntax Rules

  • horizontal-tb is the default for most web content.
  • vertical-rl and vertical-lr are widely supported for vertical layouts.
  • sideways-rl and sideways-lr rotate horizontal text; check browser support before relying on them.
  • Vertical modes swap how width and height behave for text flow — set both dimensions when needed.
  • The property is inherited.

Related Properties

  • text-orientation — controls character rotation in vertical lines
  • direction — sets inline text direction (ltr or rtl)
  • text-combine-upright — combines digits or letters in vertical text
  • margin-block-start, padding-inline — logical properties that follow writing-mode

🎯 Default Value

The default value of the writing-mode property is horizontal-tb, which means text is written horizontally and lines are stacked from top to bottom.

⚡ Quick Reference

QuestionAnswer
Default valuehorizontal-tb
Japanese vertical textwriting-mode: vertical-rl;
Lines stack left to rightwriting-mode: vertical-lr;
Pair withtext-orientation: upright;
Affects logical propertiesYes
InheritedYes

💎 Property Values

The writing-mode property accepts keyword values that define text flow and line stacking.

ValueExampleDescription
horizontal-tbwriting-mode: horizontal-tb;Text is written horizontally, and lines are stacked from top to bottom (default).
vertical-rlwriting-mode: vertical-rl;Text is written vertically, and lines are stacked from right to left.
vertical-lrwriting-mode: vertical-lr;Text is written vertically, and lines are stacked from left to right.
sideways-rlwriting-mode: sideways-rl;Text is written horizontally but rotated 90° counterclockwise, with lines stacked from right to left.
sideways-lrwriting-mode: sideways-lr;Text is written horizontally but rotated 90° clockwise, with lines stacked from left to right.
horizontal-tb vertical-rl vertical-lr sideways-rl sideways-lr

When to Use writing-mode

writing-mode is helpful when text direction is part of the design or language requirements:

  • Japanese and Chinese vertical layouts — Traditional top-to-bottom, right-to-left reading flow.
  • Sidebar and axis labels — Compact vertical labels in charts and panels.
  • Multilingual sites — Match writing direction to each language section.
  • Logical CSS layouts — Use with margin-block and padding-inline for writing-mode-aware spacing.
  • Creative typography — Vertical headlines and decorative text blocks.

👀 Live Preview

Compare default horizontal flow with vertical-rl:

Horizontal text flows left to right.
horizontal-tb
Vertical text stacks right to left.
vertical-rl

Examples Gallery

In this example, we’ll change the writing mode of a paragraph to vertical, with lines stacked from right to left.

📜 Core Patterns

Switch from default horizontal flow to vertical text layouts.

Example 1 — vertical-rl paragraph

In this example, we’ll change the writing mode of a paragraph to vertical, with lines stacked from right to left.

index.html
<style>
  p {
    writing-mode: vertical-rl;
    border: 1px solid #000;
    width: 200px;
    height: 100px;
    padding: 10px;
  }
</style>

<p>Vertical text with lines stacked right to left.</p>
Try It Yourself

How It Works

vertical-rl rotates the inline direction so characters stack vertically and new lines appear to the left of the previous line.

Example 2 — Compare writing-mode values

See how horizontal-tb, vertical-rl, and vertical-lr change text flow.

compare.css
.horizontal-tb { writing-mode: horizontal-tb; }
.vertical-rl { writing-mode: vertical-rl; }
.vertical-lr { writing-mode: vertical-lr; }
Try It Yourself

How It Works

The first keyword in each value describes inline direction; the second describes block progression (how lines stack).

📄 Layout & Language

Practical vertical text for UI labels and East Asian content.

Example 3 — Vertical sidebar label

Use vertical-rl for compact axis or panel labels without rotating the whole layout with transforms.

label.css
.sidebar-label {
  writing-mode: vertical-rl;
  font-weight: 600;
  text-transform: uppercase;
}
Try It Yourself

How It Works

Vertical writing mode keeps the label readable while using minimal horizontal space beside the main content.

Example 4 — Japanese vertical text

Combine writing-mode: vertical-rl with text-orientation: upright for traditional East Asian vertical typography.

cjk.css
.vertical-block {
  writing-mode: vertical-rl;
  text-orientation: upright;
  height: 14rem;
}
Try It Yourself

How It Works

writing-mode sets vertical flow; text-orientation: upright keeps each character upright instead of rotated sideways.

♿ Accessibility

  • Language expectations — Use vertical modes when the content language genuinely reads vertically; do not rotate body text arbitrarily.
  • Reading order — Ensure DOM order still matches the intended reading sequence for screen readers.
  • Zoom and mobile — Test vertical blocks at different viewport sizes so text remains readable.
  • Contrast and size — Vertical labels still need sufficient font size and color contrast.

writing-mode + text-orientation

Vertical layouts often need both properties: writing-mode sets line direction, and text-orientation controls how individual characters rotate within each line.

vertical-pair.css
.vertical-text {
  writing-mode: vertical-rl;
  text-orientation: upright;
}

🧠 How writing-mode Works

1

Choose a writing mode

Pick horizontal-tb, vertical-rl, vertical-lr, or a sideways value.

Input
2

Browser sets inline & block axes

Text flow and line stacking follow the chosen mode.

Axes
3

Logical properties adapt

block-start, inline-start, and related properties map to the new directions.

Layout
=

Correct text direction

Content displays in the intended horizontal or vertical flow.

Browser Compatibility

The writing-mode property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.

Modern browsers · Widely supported

Vertical & horizontal modes

horizontal-tb, vertical-rl, and vertical-lr are well supported. Test sideways-* values separately.

97% Browser support
Google Chrome 48+ · Desktop & Mobile
Full support
Mozilla Firefox 41+ · Desktop & Mobile
Full support
Apple Safari 10.1+ · macOS & iOS
Full support
Microsoft Edge 12+ · All versions
Full support
Opera 35+ · All versions
Full support

Testing tip

Test vertical Japanese or Chinese sample text in Chrome, Safari, and Firefox. Verify sideways values if you use them.

writing-mode property 97% supported

Bottom line: horizontal-tb, vertical-rl, and vertical-lr are safe for production layouts.

Conclusion

The writing-mode property is a versatile tool for web developers looking to create unique text layouts and support various writing systems.

By controlling the direction and orientation of text, you can enhance the readability and aesthetic appeal of your website. Experiment with different values and see how this property can transform the way your content is displayed.

💡 Best Practices

✅ Do

  • Use vertical-rl for Japanese and Chinese vertical content
  • Pair with text-orientation for character control
  • Set explicit width and height on vertical blocks
  • Test across browsers and mobile viewports
  • Use logical properties for writing-mode-aware spacing

❌ Don’t

  • Rotate all body text without a language reason
  • Confuse writing-mode with transform: rotate()
  • Assume sideways values work everywhere without testing
  • Forget that writing-mode affects logical CSS properties

Key Takeaways

Knowledge Unlocked

Five things to remember about writing-mode

Use these points when building horizontal or vertical text layouts.

5
Core concepts
🕐 02

horizontal-tb

Default value.

Default
🔀 03

vertical-rl

CJK layouts.

Pattern
🔄 04

text-orientation

Character rotation.

Companion
🌐 05

Logical props

Follow writing mode.

Layout

❓ Frequently Asked Questions

writing-mode controls the direction text flows and how lines are stacked — horizontally (top to bottom) or vertically (right to left or left to right).
The default is horizontal-tb, which writes text horizontally with lines stacked from top to bottom.
vertical-rl stacks lines from right to left (common in Japanese). vertical-lr stacks lines from left to right (common in some Mongolian layouts).
Yes. writing-mode changes which physical direction block-start, inline-start, and related logical properties map to.
Yes, writing-mode is inherited. Setting it on a parent affects nested text unless overridden.

Practice in the Live Editor

Open the HTML editor and compare horizontal-tb with vertical-rl and vertical-lr.

HTML Editor →

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