cssでテキストを縦書きにする方法

cssでテキストを縦書きにする方法をご紹介します。
「writing-mode」プロパティ
writing-mode は、テキストを横書きにするか縦書きにするかと、
行の流れる方向を設定できます。
・html
|
1 2 3 |
<div class="bs_vertical"> <p>縦書きテキストテキスト<br />テキストテキストテキスト<br />テキストテキストテキスト</p> </div> |
・css
|
1 2 3 4 5 |
.bs_vertical { -webkit-writing-mode: vertical-rl; -ms-writing-mode :tb-rl; writing-mode: vertical-rl; } |
writing-modeの値
writing-mode には以下の値があります。
()内はIE用のベンダープレフィックスの値です。
- horizontal-tb(lr-tb)
- 横書き 行は上から下の順に表示
- vertical-rl(tb-rl)
- 縦書き 列は右から左の順に表示
- vertical-lr(tb-lr)
- 縦書き 列は左から右の順に表示
英数字に対応「text-orientation」
writing-mode で縦書きに設定しただけでは、文章内の英数字は横向きのまま表示されてしまいます。
text-orientation を使用することで、文字も縦向きにすることができます。
IEには対応していないので注意!
・html
|
1 2 3 |
<div class="bs_vertical_upright"> <p>2021年、Olympic year。<br />テキストテキストテキスト<br />テキストテキストテキスト</p> </div> |
・css
|
1 2 3 4 5 6 |
.bs_vertical_upright { -webkit-writing-mode: vertical-rl; -ms-writing-mode :tb-rl; writing-mode: vertical-rl; text-orientation: upright; } |
縦中横(たてちゅうよこ)に対応「text-combine」
text-combine プロパティを使うことで、縦書きの中の1文字分のスペースに、複数の英数字を横書きで入れる、
縦中横(たてちゅうよこ)と呼ばれるスタイルを実現できます。
・html
|
1 2 3 |
<div class="bs_vertical"> <p>本日<span class="bs_combine">20</span>人目の<br />お客様です。</p> </div> |
・css
|
1 2 3 4 5 6 7 8 9 10 |
.bs_vertical { -webkit-writing-mode: vertical-rl; -ms-writing-mode :tb-rl; writing-mode: vertical-rl; } .bs_combine { -webkit-text-combine: horizontal; -ms-text-combine-horizontal: all; text-combine-upright: all; } |
ルビ(ふりがな)を振る「ruby」
ルビを振るには、htmlのrubyタグを使います。
ルビを振りたいテキストとルビをrubyタグで囲み、ルビは rtタグで囲みます。
・html
|
1 |
<p><ruby>縦書<rt>たてが</rt>き</ruby>テキストテキスト</p> |
以上、テキストを縦書きにする方法のご紹介でした。
タイトルやコンセプト文などの一部だけ縦書きにすることで、
デザインの幅が広がりそうです。
![MARKLEAPS[マークリープス]](https://markleaps.com/blog/wp-content/themes/mkl/images/00_logo.png)


![[CSS] shape-outside プロパティで画像にテキストを回り込ませる方法](https://markleaps.com/blog/wp-content/uploads/2025/09/css-shape-outside-500x254.jpg)
![[HTML・CSS] 説明リストdlのdtとddを横並びに表示する方法(コピペで使えるコード付き)](https://markleaps.com/blog/wp-content/uploads/2025/09/html-css-dl-flex-grid-500x254.jpg)
![[CSS] 疑似クラス is() とwhere() の使い方と違い](https://markleaps.com/blog/wp-content/uploads/2023/11/css-is-where-500x254.jpg)