One of the CSS properties that deals with how texts are displayed is the writing-mode property
.
It deals with how lines of texts are laid out, whether horizontally or vertically. It also sets the direction in which blocks will progress.
Just like other CSS properties, the writing-mode
property is set in the same way, which is:
property: value;
The writing mode
property has its values categorized into two:
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;
writing-mode: revert;
Note: Directionality of a script affects the flow direction in horizontal of that script.
Directionality of a script is either left-to-right ( ltr
, English and many other languages) or right-to-left (rtl
, Arabic and similar languages).
Values will be explained in relation to directionality of the scripts:
horizontal-tb
For ltr
scripts: Sets the content to flow from left to right.
For rtl>
scripts: Sets the content to flow horizontally from right to left. The next horizontal line is set to be positioned below the previous line.
2.vertical-rl
For ltr
scripts: sets the content to flow vertically from top to bottom, and the next vertical line is set to be positioned to the left of the previous line.
For rtl
scripts: sets the content to flow vertically from bottom to top, and the next vertical line is set to be positioned to the right of the previous line.
vertical-lr
For ltr
scripts: Sets the content to flow vertically from top to bottom and the next vertical line is set to be positioned to the right of the previous line.
For rtl
scripts:
Sets the content to flow vertically from bottom to top, and the next vertical line is to be positioned to the left of the previous line.
sideways-rl
For ltr
scripts: Sets the content to flow vertically from bottom to top.
For rlt
: Sets the content to flow vertically from top to bottom.
Note: All the characters, even those in vertical scripts, are set sideways toward the right.
sideways-lr
For ltr
scripts: Sets the content to flow vertically from top to bottom.
For rtl
scripts: Sets content to flow vertically from bottom to top.
Note: All the characters, even those in vertical scripts, are set sideways toward the left.
inherit
This set the content to get the property of the parent element. The content is set to flow in the direction of the parent element.
initial
This set the content to get the default value of the property. The content is set to flow in its normal direction.
unset
This acts as either inherit
or initial
. It will act as inherit
if the parent has a value that matches, or else it will act as initial
.
revert
This reverts the value of the property from its current value to the value it would have if this value hadn’t been specified. It sets the value to default or inherit.
All the td
are given a class to enhance easy styling. The styles are set to each writing
value we desire.
Try it with horizontal rtl
scripts for better understanding.