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.
Fundamentals
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.
Foundation
📝 Syntax
The syntax for the writing-mode property is simple and consists of specifying one of the predefined values.
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.
Preview
👀 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
Hands-On
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>
writing-mode sets vertical flow; text-orientation: upright keeps each character upright instead of rotated sideways.
A11y
♿ 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.
Companion
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.
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.
Compatibility
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 Chrome48+ · Desktop & Mobile
Full support
Mozilla Firefox41+ · Desktop & Mobile
Full support
Apple Safari10.1+ · macOS & iOS
Full support
Microsoft Edge12+ · All versions
Full support
Opera35+ · 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 property97% supported
Bottom line:horizontal-tb, vertical-rl, and vertical-lr are safe for production layouts.
Wrap Up
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.
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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about writing-mode
Use these points when building horizontal or vertical text layouts.
5
Core concepts
📚01
Text direction
Flow & stacking.
Purpose
🕐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.