Name: | direction |
---|---|
Value: | ltr | rtl |
Initial: | ltr |
Applies to: | all elements |
Inherited: | yes |
Percentages: | n/a |
Computed value: | specified value |
Canonical order: | n/a |
Animation type: | not animatable |
di
r
attribute and <bdo> element to ensure correct bidirectional layout in the absence of a style sheet. Authors should not use direction in HTML documents.
This property specifies the inline base direction or directionality
of any bidi paragraph, embedding, isolate, or override established by the box.
(See unicode-bidi.)
In addition, it informs the ordering of table column layout,
the direction of horizontal overflow,
and the default alignment of text within a line, and other layout effects
that depend on the box’s inline base direction.
Values for this property have the following meanings:
ltr
This value sets inline base direction (bidi directionality)
to line-left-to-line-right.
rtl
This value sets inline base direction (bidi directionality)
to line-right-to-line-left.
The direction property has no effect on bidi reordering
when specified on inline boxes whose unicode-bidi value is normal,
because the box does not open an additional level
of embedding with respect to the bidirectional algorithm.
The direction property, when specified for table column boxes, is not inherited by
cells in the column since columns are not the ancestors of the cells in
the document tree. Thus, CSS cannot easily capture the "dir" attribute
inheritance rules described in [HTML401], section 11.3.2.1.
Name: | unicode-bidi |
---|---|
Value: | normal | embed | isolate | bidi-override | isolate-override | plaintext |
Initial: | normal |
Applies to: | all elements, but see prose |
Inherited: | no |
Percentages: | n/a |
Computed value: | specified value |
Canonical order: | per grammar |
Animation type: | not animatable |
di
r
attribute, <bdo> element,
and appropriate distinction of text-level vs. grouping-level HTML element types to ensure correct bidirectional layout in the absence of a style sheet. Authors should not use unicode-bidi in HTML documents.
Normally (i.e. when unicode-bidiisnormal)
an inline box is transparent to the unicode bidi algorithm;
content is ordered as if the box’s boundaries were not there.
Other values of the unicode-bidi property cause inline boxes
to create scopes within the algorithm,
and to override the intrinsic directionality of text.
The following informative table summarizes the box-internal and
box-external effects of unicode-bidi:
Outside | |||
---|---|---|---|
strong | neutral | ||
Inside | scoped | embed | isolate |
override | bidi-override | isolate-override | |
plaintext | — | plaintext |
unicode-bidi value | direction value | |||
---|---|---|---|---|
ltr | rtl | |||
start | end | start | end | |
normal | — | — | — | — |
embed | LRE (U+202A) | PDF (U+202C) | RLE (U+202B) | PDF (U+202C) |
isolate | LRI (U+2066) | PDI (U+2069) | RLI (U+2067) | PDI (U+2069) |
bidi-override* | LRO (U+202D) | PDF (U+202C) | RLO (U+202E) | PDF (U+202C) |
isolate-override* | FSI,LRO (U+2068,U+202D) | PDF,PDI (U+202C,U+2069) | FSI,RLO (U+2068,U+202E) | PDF,PDI (U+202C,U+2069) |
plaintext | FSI (U+2068) | PDI (U+2069) | FSI (U+2068) | PDI (U+2069) |
* The LRO/RLO+PDF pairs are also applied to the root inline box of a block container if these values of unicode-bidi were specified on the block container. |
<section dir=rtl> <para>HEBREW1 HEBREW2 english3 HEBREW4 HEBREW5</para> <para>HEBREW6 <emphasis>HEBREW7</emphasis> HEBREW8</para> </section> <section dir=ltr> <para>english9 english10 english11 HEBREW12 HEBREW13</para> <para>english14 english15 english16</para> <para>english17 <quote dir=rtl>HEBREW18 english19 HEBREW20</quote></para> </section>Since this is arbitrary XML, the style sheet is responsible for setting the writing direction. This is the style sheet:
/* Rules for bidi */ [dir=rtl] {direction: rtl; unicode-bidi: isolate; } [dir=ltr] {direction: ltr; unicode-bidi: isolate; } /* Rules for presentation */ section, para {display: block;} emphasis {font-weight: bold;} quote {font-style: italic;}If the line length is long, the formatting of this text might look like this:
5WERBEH 4WERBEH english3 2WERBEH 1WERBEH 8WERBEH 7WERBEH 6WERBEH english9 english10 english11 13WERBEH 12WERBEH english14 english15 english16 english17 20WERBEH english19 18WERBEHThe first
<s
ect
ion
>
element is a block with a right-to-left base direction,
the second <se
cti
on>
element is a block with a left-to-right base direction.
The <p
ara
>
s are blocks that inherit the base direction from their parents.
Thus, the first two <
par
a>
s are read starting at the top right,
the final three are read starting at the top left.
The <e
mph
asi
s>
element is inline-level,
and since its value for unicode-bidiisnormal (the initial value),
it has no effect on the ordering of the text.
The <q
uot
e>
element, on the other hand,
creates an isolated sequence with the given internal directionality.
Note that this causes HEBREW18 to be to the right of english19.
If lines have to be broken, the same text might format like this:
2WERBEH 1WERBEH -EH 4WERBEH english3 5WERB -EH 7WERBEH 6WERBEH 8WERB english9 english10 en- glish11 12WERBEH 13WERBEH english14 english15 english16 english17 18WERBEH 20WERBEH english19Notice that because HEBREW18 must be read before english19, it is on the line above english19. Just breaking the long line from the earlier formatting would not have worked. Note also that the first syllable from english19 might have fit on the previous line, but hyphenation of left-to-right words in a right-to-left context, and vice versa, is usually suppressed to avoid having to display a hyphen in the middle of a line.
<para>...<i1><i2>...<BR/>...</i2></i1>...</para>and
<para>...<i1><i2>...</i2></i1><BR/><i1><i2>...</i2></i1>...</para>for all values of unicode-bidi on inline elements <i1> and <i2>. Note that this behavior is applied by CSS for CSS-declared bidi controls applied to the box tree; it does not apply to Unicode’s bidi formatting controls, which are defined to terminate their effect at the end of the bidi paragraph.
Name: | writing-mode |
---|---|
Value: | horizontal-tb | vertical-rl | vertical-lr |
Initial: | horizontal-tb |
Applies to: | All elements except table row groups, table column groups, table rows, table columns, ruby base containers, ruby annotation containers |
Inherited: | yes |
Percentages: | n/a |
Computed value: | specified value |
Canonical order: | n/a |
Animation type: | not animatable |
<
ifr
ame
>
s, for example, remain upright,
and the default object size of 300px×150px does not re-orient.
However embedded replaced content involving text
(such as MathML content or form elements)
should match the replaced element’s writing mode and line orientation
if the UA supports such a vertical writing mode for the replaced content.
In the following example, two block elements (1 and 3) separated
by an image (2) are presented in various flow writing modes.
Here is a diagram of horizontal writing mode (wr
iti
ng-
mod
e:
hor
izo
nta
l-t
b
):
wri
tin
g-m
ode
: v
ert
ica
l-r
l
):
wr
iti
ng-
mod
e:
ver
tic
al-
lr
):
<style> form { writing-mode: vertical-rl; } </style> ... <form> <p><label>姓名 <input value="艾俐俐"></label> <p><label>语言 <select><option>English <option>français <option>فارسی <option>中文 <option>日本語</select></label> </form>
svg { writing-mode: initial; }
Specified | Computed |
---|---|
lr | horizontal-tb |
lr-tb | |
rl | |
rl-tb | |
tb | vertical-rl |
tb-rl |
Authors who wish to create forwards and backwards-compatible SVG content in CSS syntax can use the CSS forwards-compatible parsing rules to do so, e.g.@namespace svg"http://www.w3.org/2000/svg" ; svg|*[ writing-mode=lr], svg|*[ writing-mode=lr-tb], svg|*[ writing-mode=rl], svg|*[ writing-mode=rl-tb] { writing-mode : horizontal-tb; } svg|*[ writing-mode=tb], svg|*[ writing-mode=tb-rl] { writing-mode : vertical-rl; }
svg|text { writing-mode: tb; writing-mode: vertical-rl; }
<p><span class="outer">Ap <span class="inner">ਜੀ</span></span></p>And the following style rule:
span.inner { font-size: .75em; }The baseline tables of the parent (
.
out
er
) and the child
(.i
nne
r
) will not match up due to the font size difference.
Since the dominant baseline is the alphabetic baseline, the child box
is aligned to its parent by matching up their alphabetic baselines.
.
inn
er
element from the example above, the same rules are used to align
the .
inn
er
child to its parent; the only difference
is in addition to the baseline alignment, the child is shifted to
the superscript position.
span.inner { vertical-align: super; font-size: .75em; }
Name: | text-orientation |
---|---|
Value: | mixed | upright | sideways |
Initial: | mixed |
Applies to: | all elements except table row groups, rows, column groups, and columns |
Inherited: | yes |
Percentages: | n/a |
Computed value: | specified value |
Canonical order: | n/a |
Animation type: | not animatable |
.vertical-upright-hebrew { writing-mode: vertical-rl; text-orientation: upright; unicode-bidi: bidi-override; direction: ltr; }
Tr
orTu
in[UAX50] are expected to have alternate glyphs or positioning for typesetting upright in vertical text.
In the case of Tr
characters,
if such vertical alternate glyphs are missing from the font,
the UA may wish to [RFC6919] (but is not expected to)
synthesize the missing glyphs by typesetting them sideways etc.
sideways typesetting
Typographic character units typeset as a run
rotated 90° clockwise from their upright orientation,
using horizontal metrics and composition,
and vertical typesetting features are not used.
However, if the font has features meant to be enabled
for sideways text that is typeset in vertical lines
(e.g. to adjust brush stroke angles or alignment),
those features are used.
(An example of such a feature would be the proposed vr
tr
OpenType font feature.)
Ve
rti
cal
_Or
ien
tat
ion
property
for the default glyph orientation of mixed-orientation vertical text.
When text-orientationismixed,
the UA must determine the orientation of each typographic character unit by its V
ert
ica
l_O
rie
nta
tio
n
property: typesetting it upright if its orientation property is U
, Tu
, or Tr
;
or typesetting it sideways (90° clockwise from horizontal)
if its orientation property is R
.
Note that UAX50 does not handle scripts that rotate -90° in vertical contexts,
so they will not be typeset correctly with mixed orientation.
The sideways-lr value in Level 4, however,
can correctly display such scripts.
The OpenType vrt2 feature, which is intended for mixed-orientation typesetting,
is not used by CSS.
It delegates the responsibility for orienting glyphs to the font designer.
CSS instead dictates the orientation through [UAX50] and orients glyphs by typesetting them sideways or upright as appropriate.
Name: | glyph-orientation-vertical |
---|---|
Value: | auto | 0deg | 90deg | 0 |90 |
Initial: | n/a |
Applies to: | n/a |
Inherited: | n/a |
Percentages: | n/a |
Computed value: | n/a |
Canonical order: | n/a |
Animation type: | n/a |
Shorthand glyph-orientation-vertical value | Longhand text-orientation value |
---|---|
auto | mixed |
0deg | upright |
0 | upright |
90deg | sideways |
90 | sideways |
writing-mode | horizontal-tb | vertical-rl | vertical-lr | |||
---|---|---|---|---|---|---|
direction | ltr | rtl | ltr | rtl | ltr | rtl |
block-size | height | width | ||||
inline-size | width | height | ||||
block-start | top | right | left | |||
block-end | bottom | left | right | |||
inline-start | left | right | top | bottom | top | bottom |
inline-end | right | left | bottom | top | bottom | top |
over | top | right | ||||
under | bottom | left | ||||
line-left | left | top | ||||
line-right | right | bottom |
min
(ma
x-c
ont
ent
in
lin
e s
ize,
ma
x(m
in-
con
ten
t i
nli
ne
siz
e,
str
etc
h-f
it
inl
ine
si
ze)
,
where the available space used to calculate the stretch-fit inline size is
either the size of the containing block if that is definite,
or else the fallback size as defined above.
The automatic sizing of orthogonal multi-column containers (in both axes)
and of other display types not mentioned above
is not defined in this specification.
Note: See also CSS Writing Modes Level 4.
bod
y
child element [HTML]
whose display value is not none
,
the used value of the of writing-mode and direction properties on root element
are taken
from the computed writing-mode and direction of the first such child element instead of from the root element’s own values.
The UA may also propagate the value of text-orientation in this manner.
Note that this does not affect the computed values of writing-mode, direction, or text-orientation of the root element itself.
Note: Using containment disables
this special handling of the HTML bo
dy
element.
See the CSS Containment 1 § 2 Strong Containment: the contain property for details.
Candidate Correction 1: Specify that the b
ody
element is ignored for determining the principal writing mode if it has display: none. Issue 3779
Note: Propagation is done on used values rather than computed values
to avoid disrupting other aspects of style computation,
such as inheritance, logical property mapping logic,
or length value computation.
principal writing mode | page progression |
---|---|
horizontal-tb and ltr | left-to-right |
horizontal-tb and rtl | right-to-left |
vertical-rl | right-to-left |
vertical-lr | left-to-right |
Name: | text-combine-upright |
---|---|
Value: | none | all |
Initial: | none |
Applies to: | inline boxes and text |
Inherited: | yes |
Percentages: | n/a |
Computed value: | specified keyword |
Canonical order: | n/a |
Animation type: | not animatable |
date span { text-combine-upright: all; }and the following markup:
<date>平成<span>20</span>年4月<span>16</span>日に</date>
In Japanese, this effect is known as tate-chu-yoko.
Future levels of CSS Writing Modes will introduce values
to automatically detect commonly-affected sequences.
For example, CSS Writing Modes Level 4 introduces the digits value to combine sequences of digits.
tcy { text-combine-upright: all; }if the following markup were given:
<tcy>12<span>34</span></tcy>no text would combine.
hwi
d
/t
wid
/qw
id
;
other glyph-width features such as fwi
d
orp
wid
are not included)
to compress text
in cases where those variants are available for all typographic character units in the composition.
Otherwise, the UA may use any means to compress the text,
including substituting half-width, third-width, and/or quarter-width glyphs provided by the font,
using other font features designed to compress text horizontally,
scaling the text geometrically,
or any combination thereof.
For example, a simple OpenType-based implementation might compress the text as follows:
(一)Enable 1/n-width glyphs for combined text of ntypographic character units (i.e. use OpenType h
wid
for 2 typographic character units, twi
d
for 3 typographic character units, etc.)
if the number of typographic character units > 1.
Note that the number of typographic character units ≠ number of Unicode codepoints!
(二)If the result is wider than 1em, horizontally scale the result to 1em.
A different implementation that utilizes OpenType layout features
might compose the text first with normal glyphs to see if that fits,
then substitute in half-width or third-width forms as available and necessary,
possibly adjusting its approach or combining it with scaling operations
depending on the available glyph substitutions.
In some fonts, the ideographic glyphs are given a compressed design
such that they are 1em wide but shorter than 1em tall.
To accommodate such fonts, the UA may vertically scale the composition
to match the advance height of 水 U+6C34
as rendered according to the specified font settings.
In such a case the resulting composition assumes
the advance height of 水 U+6C34 rather than 1em.
bo
dy
element does not influence the principal writing mode.
(Issue 3779)
●Updated “Applies to” line for text-combine-upright to mention text
(since certain effects like display: contents can strip the box itself).
●Clarified that the central baseline is the ideographic central baseline.
(Issue 5177)
●Reshuffled text in the and improved cross-linking.
Code | Name | Transform (Clockwise) | Vertical Intrinsic Direction |
---|---|---|---|
Bopo | Bopomofo | 0° | ttb |
Egyp | Egyptian Hieroglyphs | 0° | ttb |
Hira | Hiragana | 0° | ttb |
Kana | Katakana | 0° | ttb |
Hani | Han | 0° | ttb |
Hang | Hangul | 0° | ttb |
Merc | Meroitic Cursive | 0° | ttb |
Mero | Meroitic Hieroglyphs | 0° | ttb |
Mong | Mongolian | 90° | ttb |
Ogam | Ogham | -90° | btt |
Orkh | Old Turkic | -90° | ttb |
Phag | Phags Pa | 90° | ttb |
Yiii | Yi | 0° | ttb |
cl
ass
="e
xam
ple
"
,
like this:
This is an example of an informative example.
Informative notes begin with the word “Note” and are set apart from the
normative text with c
las
s="
not
e"
, like this:
Note, this is an informative note.
Advisements are normative sections styled to evoke special attention and are
set apart from other normative text with <s
tro
ng
cla
ss=
"ad
vis
eme
nt"
>
, like
this: UAs MUST provide an accessible alternative.
Name | Value | Initial | Applies to | Inh. | %ages | Animation type | Canonical order | Computed value |
---|---|---|---|---|---|---|---|---|
direction | ltr | rtl | ltr | all elements | yes | n/a | not animatable | n/a | specified value |
glyph-orientation-vertical | auto | 0deg | 90deg | 0 | 90 | n/a | n/a | n/a | n/a | n/a | n/a | n/a |
text-combine-upright | none | all | none | inline boxes and text | yes | n/a | not animatable | n/a | specified keyword |
text-orientation | mixed | upright | sideways | mixed | all elements except table row groups, rows, column groups, and columns | yes | n/a | not animatable | n/a | specified value |
unicode-bidi | normal | embed | isolate | bidi-override | isolate-override | plaintext | normal | all elements, but see prose | no | n/a | not animatable | per grammar | specified value |
writing-mode | horizontal-tb | vertical-rl | vertical-lr | horizontal-tb | All elements except table row groups, table column groups, table rows, table columns, ruby base containers, ruby annotation containers | yes | n/a | not animatable | n/a | specified value |