Summary
The writing-mode
property defines whether lines of text are laid out horizontally or vertically and the direction in which blocks progress.
The property specifies the block flow direction, which is the direction in which block-level containers are stacked, and the direction in which inline-level content flows within a block container. Thus the writing-mode
property also determines the ordering of block-level content.
{{cssinfo}}
Syntax
/* Keyword values */ writing-mode: horizontal-tb; writing-mode: vertical-rl; writing-mode: vertical-lr; /* Global values */ writing-mode: inherit; writing-mode: initial; writing-mode: unset;
Values
horizontal-tb
- Content flows horizontally from left to right, vertically from top to bottom. The next horizontal line is positioned below the previous line.
vertical-rl
- Content flows vertically from top to bottom, horizontally from right to left. The next vertical line is positioned to the left of the previous line.
vertical-lr
- Content flows vertically from top to bottom, horizontally from left to right. The next vertical line is positioned to the right of the previous line.
sideways-rl
{{experimental_inline}}- Content flows vertically from top to bottom and all the glyphs, even those in vertical scripts, are set sideways toward the right.
sideways-lr
{{experimental_inline}}- Content flows vertically from top to bottom and all the glyphs, even those in vertical scripts, are set sideways toward the left.
lr
{{deprecated_inline}}- Deprecated except for SVG1 documents. For CSS, use
horizontal-tb
. lr-tb
{{deprecated_inline}}- Deprecated except for SVG1 documents. For CSS, use
horizontal-tb
. rl
{{deprecated_inline}}- Deprecated except for SVG1 documents. For CSS, use
horizontal-tb
. tb
{{deprecated_inline}}- Deprecated except for SVG1 documents. For CSS, use
vertical-rl
. tb-rl
{{deprecated_inline}}- Deprecated except for SVG1 documents. For CSS, use
vertical-rl
.
Formal syntax
{{csssyntax}}
Example
<table> <tr> <th>value</th> <th>Vertical script</th> <th>Horizontal script</th> <th>Mixed script</th> </tr> <tr> <td>horizontal-tb</td> <td class="exampleText1">我家没有电脑。</td> <td class="exampleText1">Example text</td> <td class="exampleText1">1994年に至っては</td> </tr> <tr> <td>vertical-lr</td> <td class="exampleText2">我家没有电脑。</td> <td class="exampleText2">Example text</td> <td class="exampleText2">1994年に至っては</td> </tr> <tr> <td>vertical-rl</td> <td class="exampleText3">我家没有电脑。</td> <td class="exampleText3">Example text</td> <td class="exampleText3">1994年に至っては</td> </tr> <tr> <td>sideways-lr</td> <td class="exampleText4">我家没有电脑。</td> <td class="exampleText4">Example text</td> <td class="exampleText4">1994年に至っては</td> </tr> <tr> <td>sideways-rl</td> <td class="exampleText5">我家没有电脑。</td> <td class="exampleText5">Example text</td> <td class="exampleText5">1994年に至っては</td> </tr>
table { border-collapse:collapse; } td, th {border: 1px black solid; padding: 3px; } th {background-color: lightgray; } .exampleText1 { width:75px; writing-mode: horizontal-tb;} .exampleText2 { height:75px; writing-mode: vertical-lr; } .exampleText3 { height:75px; writing-mode: vertical-rl; } .exampleText4 { height:75px; writing-mode: sideways-lr; } .exampleText5 { height:75px; writing-mode: sideways-rl; }
{{EmbedLiveSample("Example", 400, 430)}}
Specification
Specification | Status | Comment |
---|---|---|
{{SpecName("CSS3 Writing Modes", "#block-flow", "writing-mode")}} | {{Spec2("CSS3 Writing Modes")}} | Initial definition |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 8{{property_prefix("-webkit")}} | {{CompatGeckoDesktop(41)}}[1][3] | 9.0 {{property_prefix("-ms")}}[2] | 15{{property_prefix("-webkit")}} | 5.1{{property_prefix("-webkit")}} |
SVG 1.1 values lr , lr-tb , rl , tb , tb-rl |
48[4] | {{CompatGeckoDesktop(43)}} | 9.0 {{property_prefix("-ms")}}[2] | {{CompatVersionUnknown}} | {{CompatUnknown}} |
sideways-rl,sideways-lr |
{{CompatNo}}[4] | {{CompatGeckoDesktop(43)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 3{{property_prefix("-webkit")}} | 47{{property_prefix("-webkit")}} | {{CompatGeckoMobile(41)}} [1][3] | {{CompatUnknown}} | {{CompatUnknown}} | 5.1 {{property_prefix("-webkit")}} |
SVG 1.1 values lr , lr-tb , rl , tb , tb-rl |
{{CompatUnknown}} | {{CompatUnknown}} | {{CompatGeckoMobile(43)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
sideways-rl,sideways-lr |
{{CompatNo}}[4] | {{CompatNo}}[4] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
[1] An experimental implementation was available since Gecko 36. It is governed by the preference layout.css.vertical-text.enabled
, defaulting to false
until Firefox 38. From Firefox 39 and Firefox 40, the preference was true
for Nightly and DevTools editions only. Note that not all CSS widgets (e.g. tables) obey to it, yet.
[2] The implementation in Internet Explorer differs from the specification. See the related article in the Internet Explorer Dev Center.
[3] Bidirectional and rtl scripts are supported in vertical modes only since Gecko 42.
[4] Chrome Unprefix CSS Writing Modes (Bug533448)
See also
- SVG
writing-mode
attribute - {{Cssxref("direction")}}
- {{Cssxref("unicode-bidi")}}
- {{Cssxref("text-orientation")}}
- {{Cssxref("text-combine-upright")}}