π What is writing-mode?
writing-mode is a CSS property that controls the direction in which text and inline content flow. Instead of always flowing left-to-right horizontally, you can rotate the writing flow to vertical layouts β common in East Asian typography, banners, labels, and dashboards.
Note
β Works with text, inline elements, tables, and block elements
β Essential for vertical layouts and creative UI designs
π― Why Use writing-mode?
- Create vertical navigation menus
- Design East-Asian vertical text (Chinese, Japanese, Korean)
- Make badges or labels in dashboards
- Rotate text without using transforms
- Control block & inline flow direction independently
π Syntax
writing-mode Syntax
writing-mode: horizontal-tb | vertical-rl | vertical-lr;π Values Explained
| Value | Meaning |
|---|---|
| horizontal-tb (default) | Text flows left β right, lines stack top β bottom |
| vertical-rl | Text flows top β bottom, lines stack right β left |
| vertical-lr | Text flows top β bottom, lines stack left β right |
Note
π§ͺ Example 1 β Vertical Text (Right β Left)
vertical-rl Example
.vertical {
writing-mode: vertical-rl;
border: 1px solid #ccc;
padding: 10px;
}Text flows downward, and each line moves toward the left edge.
π§ͺ Example 2 β Vertical Text (Left β Right)
vertical-lr Example
.vertical-left {
writing-mode: vertical-lr;
border: 1px solid #ccc;
padding: 10px;
}Similar to Japanese manga layout β text flows vertically but advances to the right.
π§ͺ Example 3 β Horizontal (Normal)
horizontal example
.horizontal {
writing-mode: horizontal-tb;
}π Writing Mode Effects
Writing mode changes how block and inline axes behave:
| Mode | Inline Axis | Block Axis |
|---|---|---|
| horizontal-tb | Left β Right | Top β Bottom |
| vertical-rl | Top β Bottom | Right β Left |
| vertical-lr | Top β Bottom | Left β Right |
Note
π¨ Example β Vertical Sidebar Navigation
Vertical Nav
.side-nav {
writing-mode: vertical-rl;
text-orientation: upright;
font-size: 1.2rem;
background: #111;
color: white;
padding: 20px;
height: 100vh;
}text-orientation: upright keeps letters upright rather than rotated.
π§ text-orientation (Important Partner Property)
text-orientation Example
.vertical {
writing-mode: vertical-rl;
text-orientation: upright;
}Ensures Latin letters remain upright instead of rotated sideways.
π± Example β Vertical Labels in Dashboard UI
Dashboard Labels
.label {
writing-mode: vertical-lr;
text-orientation: upright;
background: #f4f4f4;
padding: 10px;
border-radius: 6px;
}π§© writing-mode with Flexbox & Grid
Writing mode changes the meaning of block/inline sizes:
Flexbox Example
.flex {
display: flex;
writing-mode: vertical-rl;
gap: 10px;
}Now βrowβ becomes vertical and βcolumnβ becomes horizontal!
β οΈ Common Mistakes
- β Using writing-mode to rotate text when transform: rotate() is better
- β Forgetting text-orientation when using Latin characters vertically
- β Expecting writing-mode to work on background-position or non-text items
- β Misunderstanding block/inline axis changes in flex & grid
Note
π₯ Summary
writing-mode lets you control the direction of text flow, enabling powerful layout possibilities from vertical headers to complex Asian typography. Combined with text-orientation, it opens new creative options for modern UI and design systems.
Learn more βMDN Docs π