In modern browsers, the writing-mode
property can be set to a vertical value to vertically display form controls with text characters that are normally horizontal (for example in Latin languages), with text displayed at a 90-degree angle from the default. Normally vertical text characters, for example in Chinese or Japanese, are unaffected in this regard.
This is useful when creating vertical language forms.
Specifically:
-
writing-mode: vertical-lr
will create vertical form controls with a left-to-right block flow direction, meaning that in controls with wrapping or multiple lines of text, subsequent lines will appear to the right of previous lines. -
writing-mode: vertical-rl
will create vertical form controls with a right-to-left block flow direction, meaning that in controls with wrapping or multiple lines of text, subsequent lines will appear to the left of previous lines.
You could use a transform to rotate the controls by 90 degrees, but that would place the controls in their own layer and cause unintended layout side effects such as other content being overlapped. Using writing-mode
offers a more reliable solution.
Note: While the writing-mode
property is well supported, creating vertically-oriented form controls with writing-mode
only gained full browser support in 2024.
Note: The experimental sideways-lr
and sideways-rl
values have a similar effect as vertical-lr
and vertical-rl
respectively, except that normally vertical text characters (for example in Chinese or Japanese) are rotated 90 degrees to display on their sides, while horizontal text characters (for example in Latin languages) are unaffected by these values.
In addition, the direction
property can be used to control the direction of the content inside the controls:
-
direction: ltr
will cause the content to start at the top and flow towards the bottom. -
direction: rtl
will cause the content to start at the bottom and flow towards the top.
The direction
property can be used to set the inline base direction — the primary direction in which content is ordered on a line, which defines on which sides the "start" and "end" of a line are. For text-based form controls the difference is obvious — the flow of text starts at the top or bottom. In non-text-based controls such as range sliders, direction
sets the direction in which the control is drawn. For example, including direction: ltr
on a vertical slider sets the lowest value at the top of the slider and the highest value at the bottom of the slider.
The sections below show how to create different types of vertical form control, along with examples of each. Consult the browser compatibility information on each of the linked reference pages to find out the exact support information for each type.