CSS for Native Chinese

Gao
I want to write some native chinese (ancient chinese) which is write from right to left, up to down format. In Web, there are new css properties `writing-mode` and `text-orientation` can resolve this situation. ## `writing-mode` The writing-mode [CSS](https://developer.mozilla.org/en-US/docs/Web/CSS) property sets whether lines of text are laid out horizontally or vertically, as well as the direction in which blocks progress. When set for an entire document, it should be set on the root element (html element for HTML documents). This 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, it also determines the ordering of block-level content. ### Syntax ```css /* Keyword values */ writing-mode: horizontal-tb; writing-mode: vertical-rl; writing-mode: vertical-lr; /* Global values */ writing-mode: inherit; writing-mode: initial; writing-mode: revert; writing-mode: revert-layer; writing-mode: unset; ``` The `writing-mode` property is specified as one of the values listed below. The flow direction in horizontal scripts is also affected by the [directionality of that script](https://www.w3.org/International/questions/qa-scripts.en) , either left-to-right (ltr, like English and most other languages) or right-to-left (rtl, like Hebrew or Arabic). ### Values * `horizontal-tb` For ltr scripts, content flows horizontally from left to right. For rtl scripts, content flows horizontally from right to left. The next horizontal line is positioned below the previous line. * `vertical-rl` For ltr scripts, content flows vertically from top to bottom, and the next vertical line is positioned to the left of the previous line. For rtl scripts, content flows vertically from bottom to top, and the next vertical line is positioned to the right of the previous line. * `vertical-lr` For ltr scripts, content flows vertically from top to bottom, and the next vertical line is positioned to the right of the previous line. For rtl scripts, content flows vertically from bottom to top, and the next vertical line is positioned to the left of the previous line. * `sideways-rl ` Experimental For ltr scripts, content flows vertically from top to bottom. For rtl scripts, content flows vertically from bottom to top. All the glyphs, even those in vertical scripts, are set sideways toward the right. * `sideways-lr ` Experimental For ltr scripts, content flows vertically from bottom to top. For rtl scripts, content flows vertically from top to bottom. All the glyphs, even those in vertical scripts, are set sideways toward the left. ### Formal syntax ``` writing-mode = horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr ``` ### Examples ### Using multiple writing modes This example demonstrates all of the writing modes, showing each with text in various languages. #### HTML The HTML is a `<table>` with each writing mode in a row with a column showing text in various scripts using that writing mode. ```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> ``` #### CSS The CSS that adjusts the directionality of the content looks like this: ```css .example.Text1 span, .example.Text1 { writing-mode: horizontal-tb; } .example.Text2 span, .example.Text2 { writing-mode: vertical-lr; } .example.Text3 span, .example.Text3 { writing-mode: vertical-rl; } .example.Text4 span, .example.Text4 { writing-mode: sideways-lr; } .example.Text5 span, .example.Text5 { writing-mode: sideways-rl; } ``` #### Result ![](https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode/screenshot_2020-02-05_21-04-30.png) ## `text-orientation` The text-orientation [CSS](https://developer.mozilla.org/en-US/docs/Web/CSS) property sets the orientation of the text characters in a line. It only affects text in vertical mode (when [writing-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode) is not horizontal-tb). It is useful for controlling the display of languages that use vertical script, and also for making vertical table headers. ### Syntax ```css /* Keyword values */ text-orientation: mixed; text-orientation: upright; text-orientation: sideways-right; text-orientation: sideways; text-orientation: use-glyph-orientation; /* Global values */ text-orientation: inherit; text-orientation: initial; text-orientation: revert; text-orientation: revert-layer; text-orientation: unset; ``` The text-orientation property is specified as a single keyword from the list below. ### Values - `mixed` Rotates the characters of horizontal scripts 90° clockwise. Lays out the characters of vertical scripts naturally. Default value. * `upright` Lays out the characters of horizontal scripts naturally (upright), as well as the glyphs for vertical scripts. Note that this keyword causes all characters to be considered as left-to-right: the used value of [direction](https://developer.mozilla.org/en-US/docs/Web/CSS/direction) is forced to be ltr. * `sideways` Causes characters to be laid out as they would be horizontally, but with the whole line rotated 90° clockwise. * `sideways-right` An alias to sideways that is kept for compatibility purposes. * `use-glyph-orientation` On SVG elements, this keyword leads to use the value of the deprecated SVG properties glyph-orientation-vertical and glyph-orientation-horizontal. ### Examples #### HTML ```html <p>Lorem ipsum dolet semper quisquam.</p> ``` #### CSS ```css p { writing-mode: vertical-rl; text-orientation: upright; } ```