--- title: writing-mode slug: Web/CSS/writing-mode tags: - CSS - Layout - Propriedade CSS - Referencia translation_of: Web/CSS/writing-mode ---
A propriedade CSS writing-mode
define se as linhas do texto são dispostas horizontalmente ou verticalmente e a direção que os blocos seguem
/* Valores das palavras-chave */ writing-mode: horizontal-tb; writing-mode: vertical-rl; writing-mode: vertical-lr; /* Valores globais */ writing-mode: inherit; writing-mode: initial; writing-mode: unset;
A propriedade especifica o comportamento de fluxo do bloco, que é a maneira em que os containers são empilhados ou distribuídos, e a direção em que o conteudo é alinhado ou disposto dentro dos containers. Assim a propriedade writing-mode
também determina a distribuição do conteúdo no nível de bloco
{{cssinfo}}
horizontal-tb
vertical-rl
vertical-lr
sideways-rl
{{experimental_inline}}sideways-lr
{{experimental_inline}}lr
{{deprecated_inline}}horizontal-tb
.lr-tb
{{deprecated_inline}}horizontal-tb
.rl
{{deprecated_inline}}horizontal-tb
.tb
{{deprecated_inline}}vertical-lr
.tb-rl
{{deprecated_inline}}vertical-rl
.Esse exemplo demonstra todos os modos de escrita, mostrando cada um com texto e várias línguas.
O HTML é simplesmente um {{HTMLElement("table")}} com cada modo de escrita em uma linha com uma coluna mostrando texto em diversos scripts usando esse modo de escrita.
<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="example Text1"><span>我家没有电脑。</span></td> <td class="example Text1"><span>Example text</span></td> <td class="example Text1"><span>1994年に至っては</span></td> </tr> <tr> <td>vertical-lr</td> <td class="example Text2"><span>我家没有电脑。</span></td> <td class="example Text2"><span>Example text</span></td> <td class="example Text2"><span>1994年に至っては</span></td> </tr> <tr> <td>vertical-rl</td> <td class="example Text3"><span>我家没有电脑。</span></td> <td class="example Text3"><span>Example text</span></td> <td class="example Text3"><span>1994年に至っては</span></td> </tr> <tr> <td>sideways-lr</td> <td class="example Text4"><span>我家没有电脑。</span></td> <td class="example Text4"><span>Example text</span></td> <td class="example Text4"><span>1994年に至っては</span></td> </tr> <tr> <td>sideways-rl</td> <td class="example Text5"><span>我家没有电脑。</span></td> <td class="example Text5"><span>Example text</span></td> <td class="example Text5"><span>1994年に至っては</span></td> </tr> </table>
Apenas um CSS preparatório para fazer as coisas parecerem um pouco melhor:
table { border-collapse:collapse; } td, th { border: 1px black solid; padding: 3px; } th { background-color: lightgray; } .example { height:75px; width:75px; }
O CSS que ajusta a direcionalidade do conteúdo é algo como esse:
.example.Text1 span, .example.Text1 { writing-mode: horizontal-tb; -webkit-writing-mode: horizontal-tb; -ms-writing-mode: horizontal-tb; } .example.Text2 span, .example.Text2 { writing-mode: vertical-lr; -webkit-writing-mode: vertical-lr; -ms-writing-mode: vertical-lr; } .example.Text3 span, .example.Text3 { writing-mode: vertical-rl; -webkit-writing-mode: vertical-rl; -ms-writing-mode: vertical-rl; } .example.Text4 span, .example.Text4 { writing-mode: sideways-lr; -webkit-writing-mode: sideways-lr; -ms-writing-mode: sideways-lr; } .example.Text5 span, .example.Text5 { writing-mode: sideways-rl; -webkit-writing-mode: sideways-rl; -ms-writing-mode: sideways-rl; }
{{EmbedLiveSample("Example", 400, 500)}}
Essa é uma imagem mostrando o que o resultado deve parecer, no caso do suporte do seu navegador para writing-mode
estiver incompleto.
Especificação | Status | Comentário |
---|---|---|
{{SpecName("CSS3 Writing Modes", "#block-flow", "writing-mode")}} | {{Spec2("CSS3 Writing Modes")}} | Definição inicial |
{{SpecName("CSS4 Writing Modes", "#block-flow", "writing-mode")}} | {{Spec2("CSS4 Writing Modes")}} | Adicionar sideways-lr e sideways-rl |
{{CompatibilityTable}}
Característica | Chrome | Edge | Firefox | Internet Explorer (defunct) | Opera | Safari |
---|---|---|---|---|---|---|
Suporte básico | {{CompatChrome(8)}}{{property_prefix("-webkit")}} {{CompatVersionUnknown}} |
{{CompatVersionUnknown}}{{property_prefix("-webkit")}} {{CompatVersionUnknown}} |
{{CompatGeckoDesktop(41)}}[1][3] | 9{{property_prefix("-ms")}}[2] | {{CompatOpera(15)}}{{property_prefix("-webkit")}} | 5.1{{property_prefix("-webkit")}} |
lr |
{{CompatChrome(48)}} (uprefixed) | {{CompatVersionUnknown}} | {{CompatGeckoDesktop(43)}} | 9{{property_prefix("-ms")}}[2] | {{CompatVersionUnknown}} | {{CompatUnknown}} |
lr-tb |
||||||
rl |
||||||
rl-tb |
||||||
tb |
||||||
tb-rl |
||||||
horizontal-tb |
{{CompatVersionUnknown}} (as of 58) | {{CompatVersionUnknown}} (as of 40) | {{CompatGeckoDesktop(43)}} | {{CompatNo}} (as of 11) | {{CompatVersionUnknown}} (as of 44) | {{CompatUnknown}} |
vertical-lr |
||||||
vertical-rl |
||||||
sideways-lr |
{{CompatNo}} (as of 58) | {{CompatNo}} (as of 40) | {{CompatGeckoDesktop(43)}} | {{CompatNo}} (as of 11) | {{CompatNo}} (as of 44) | {{CompatUnknown}} |
sideways-rl |
Característica | Android | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | |
---|---|---|---|---|---|---|---|---|---|
Suporte básico | {{CompatChrome(3)}}{{property_prefix("-webkit")}} | {{CompatVersionUnknown}} | 47{{property_prefix("-webkit")}} {{CompatVersionUnknown}} |
{{CompatVersionUnknown}}{{property_prefix("-webkit")}} {{CompatVersionUnknown}} |
{{CompatGeckoMobile(41)}} [1][3] | {{CompatUnknown}} | {{CompatUnknown}} | 5.1 {{property_prefix("-webkit")}} | |
SVG 1.1 values lr , lr-tb , rl , tb , tb-rl |
{{CompatUnknown}} | {{CompatChrome(48.0)}} (uprefixed) | {{CompatChrome(48.0)}} (uprefixed) | {{CompatVersionUnknown}} | {{CompatGeckoMobile(43)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | |
sideways-rl,sideways-lr |
{{CompatNo}}[4] | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | |
vertical-lr |
vertical-rl |
{{CompatNo}}[4] | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{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. The preference has been removed in Gecko 51 and this property cannot be disabled since this version.
[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.
writing-mode
attribute