--- title: writing-mode slug: Web/CSS/writing-mode tags: - CSS - CSS プロパティ - CSS 書字方向 - Reference - リファレンス - レイアウト - 日本語処理 translation_of: Web/CSS/writing-mode --- <div>{{CSSRef}}</div> <p><strong><code>writing-mode</code></strong> は <a href="/ja/docs/Web/CSS">CSS</a> のプロパティで、テキストの行のレイアウトを横書きにするか縦書きにするか、ブロックのフロー方向を左向きにするか右向きにするかを設定します。文書全体に設定する場合は、ルート要素 (HTML 文書の場合は <code>html</code> 要素) に設定してください。</p> <div>{{EmbedInteractiveExample("pages/css/writing-mode.html")}}</div> <p class="hidden">このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力したい場合は、 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> をクローンしてプルリクエストを送信してください。</p> <p>このプロパティは、<em>ブロックのフロー方向</em>を指定します。これは、ブロックレベルコンテナが積まれる方向と、インラインレベルのコンテンツがブロックコンテナ内でフローする方向です。このように、 <code>writing-mode</code> プロパティはブロックレベルのコンテンツの順序も決定します。</p> <h2 id="Syntax" name="Syntax">構文</h2> <pre class="brush:css no-line-numbers">/* キーワードの値 */ writing-mode: horizontal-tb; writing-mode: vertical-rl; writing-mode: vertical-lr; /* グローバルの値 */ writing-mode: inherit; writing-mode: initial; writing-mode: unset;</pre> <p><code>writing-mode</code> プロパティは、以下のいずれかの値として指定されます。横書きの場合は<a href="https://www.w3.org/International/questions/qa-scripts.en">その言葉の書字方向</a>も影響し、左書き (<code>ltr</code>、英語やその他の多くの言葉) や右書き (<code>rtl</code>、ヘブライ語やアラビア語) のどちらかになります。</p> <h3 id="Values" name="Values">値</h3> <dl> <dt><code>horizontal-tb</code></dt> <dd><code>ltr</code> の言語では、コンテンツは左から右へ水平に流れます。 <code>rtl</code> の言語では、コンテンツは右から左へ水平に流れます。次の水平の行は、前の行の下に配置されます。</dd> <dt><code>vertical-rl</code></dt> <dd><code>ltr</code> の言語では、コンテンツは上から下へ垂直に流れ、次の垂直の行は、前の行の左に配置されます。 <code>rtl</code> の言語では、コンテンツは下から上へ垂直に流れ、次の垂直の行は前の行の右に配置されます。</dd> <dt><code>vertical-lr</code></dt> <dd><code>ltr</code> の言語では、コンテンツは上から下へ垂直に流れ、次の垂直の行は、前の行の右に配置されます。 <code>rtl</code> の言語では、コンテンツは下から上へ垂直に流れ、次の垂直の行は前の行の左に配置されます。</dd> <dt><code>sideways-rl</code> {{experimental_inline}}</dt> <dd><code>ltr</code> の言語では、コンテンツは下から上へ垂直に流れます。 <code>rtl</code> の言語では、コンテンツは上から下へ垂直に流れます。垂直方向に並べられる書体を含むすべてのグリフを右へ横倒しにします。</dd> <dt><code>sideways-lr</code> {{experimental_inline}}</dt> <dd><code>ltr</code> の言語では、コンテンツは上から下へ垂直に流れます。 <code>rtl</code> の言語では、コンテンツは下から上へ垂直に流れます。垂直方向に並べられる書体を含むすべてのグリフを左へ横倒しにします。</dd> <dt><code>lr</code> {{deprecated_inline}}</dt> <dd>SVG1 文書を除き、非推奨です。CSS では、<code>horizontal-tb</code> を代わりに使用してください。</dd> <dt><code>lr-tb</code> {{deprecated_inline}}</dt> <dd>SVG1 文書を除き、非推奨です。CSS では、<code>horizontal-tb</code> を代わりに使用してください。</dd> <dt><code>rl</code> {{deprecated_inline}}</dt> <dd>SVG1 文書を除き、非推奨です。CSS では、<code>horizontal-tb</code> を代わりに使用してください。</dd> <dt><code>tb</code> {{deprecated_inline}}</dt> <dd>SVG1 文書を除き、非推奨です。CSS では、<code>vertical-rl</code> を代わりに使用してください。</dd> <dt><code>tb-rl</code> {{deprecated_inline}}</dt> <dd>SVG1 文書を除き、非推奨です。CSS では、<code>vertical-rl</code> を代わりに使用してください。</dd> </dl> <h3 id="Formal_syntax" name="Formal_syntax">正式な構文</h3> {{csssyntax}} <h2 id="Example" name="Example">例</h2> <p>この例では、すべての書字方向を示し、各モードでさまざまな言語のテキストを表示します。</p> <h3 id="HTML">HTML</h3> <p>HTML は単純な {{HTMLElement("table")}} であり、行方向に書字方向を、列方向にその書字方向を使用して、さまざまな種類のテキストが表示される様子を表します。</p> <pre class="brush: html"><table> <tr> <th>Value</th> <th>Vertical script</th> <th>Horizontal (LTR) script</th> <th>Horizontal (RTL) 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>מלל ארוך לדוגמא</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>מלל ארוך לדוגמא</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>מלל ארוך לדוגמא</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>מלל ארוך לדוגמא</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>מלל ארוך לדוגמא</span></td> <td class="example Text5"><span>1994年に至っては</span></td> </tr> </table> </pre> <h3 id="CSS">CSS</h3> <div class="hidden"> <p>いくつかの予備的な CSS だけで、少し良く見えるようになります。</p> <pre class="brush: css">table { border-collapse:collapse; } td, th { border: 1px black solid; padding: 3px; } th { background-color: lightgray; } .example { height:75px; width:75px; }</pre> </div> <p>コンテンツの方向を調整する CSS は次のようになります。</p> <pre class="brush:css;">.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; } </pre> <h3 id="Actual_result" name="Actual_result">結果</h3> <p>{{EmbedLiveSample("Example", 400, 500)}}</p> <p>以下の画像は、ブラウザーの <code>writing-mode</code> の対応が不完全な場合のために、出力結果がどのように見えるかを示したものです。</p> <p><img alt="" src="https://mdn.mozillademos.org/files/17087/Screenshot_2020-02-05_21-04-30.png" style="height: 508px; width: 493px;"></p> <h2 id="Specifications" name="Specifications">仕様書</h2> <table class="standard-table"> <thead> <tr> <th scope="col">仕様書</th> <th scope="col">状態</th> <th scope="col">備考</th> </tr> </thead> <tbody> <tr> <td>{{SpecName("CSS4 Writing Modes", "#block-flow", "writing-mode")}}</td> <td>{{Spec2("CSS4 Writing Modes")}}</td> <td><code>sideways-lr</code> および <code>sideways-rl</code> を追加</td> </tr> <tr> <td>{{SpecName("CSS3 Writing Modes", "#block-flow", "writing-mode")}}</td> <td>{{Spec2("CSS3 Writing Modes")}}</td> <td>初回定義</td> </tr> </tbody> </table> <p>{{cssinfo}}</p> <h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> <p>{{Compat("css.properties.writing-mode")}}</p> <h2 id="See_also" name="See_also">関連情報</h2> <ul> <li>SVG <code><a href="/ja/docs/Web/SVG/Attribute/writing-mode">writing-mode</a></code> 属性</li> <li>{{Cssxref("direction")}}</li> <li>{{Cssxref("unicode-bidi")}}</li> <li>{{Cssxref("text-orientation")}}</li> <li>{{Cssxref("text-combine-upright")}}</li> <li><a href="/ja/docs/Web/CSS/CSS_Logical_Properties">CSS 論理的プロパティ</a></li> <li><a href="https://www.w3.org/International/articles/vertical-text/">Styling vertical text (Chinse, Japanese, Korean and Mongolian)</a></li> <li>広範なブラウザーの対応試験結果: <a href="https://w3c.github.io/i18n-tests/results/writing-mode-vertical">https://w3c.github.io/i18n-tests/results/writing-mode-vertical</a></li> </ul>