This page was translated from English by the community.Learn more and join the MDN Web Docs community.
direction
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since июль 2015 г..
* Some parts of this feature may have varying levels of support.
Thedirection CSS property sets the direction of text, table columns, and horizontal overflow. Usertl for languages written from right to left (like Hebrew or Arabic), andltr for those written from left to right (like English and most other languages).
In this article
Интерактивный пример
direction: ltr;direction: rtl;<section> <div> <div>1</div> <div>2</div> <div>3</div> <div>4</div> </div></section>#example-element { border: 1px solid #c5c5c5; padding: 0.75em; width: 80%; max-height: 300px; display: flex;}#example-element > div { background-color: rgba(0, 0, 255, 0.2); border: 3px solid blue; margin: 10px; flex: 1;}Заметьте, что направление текста обычно задано в документе (т.е. с помощьюHTML'sdir attribute), а не посредством прямого использования свойстваdirection.
The property sets the base text direction of block-level elements and the direction of embeddings created by theunicode-bidi property. It also sets the default alignment of text, block-level elements, and the direction that cells flow within a table row.
Unlike thedir attribute in HTML, thedirection property is not inherited from table columns into table cells, since CSS inheritance follows the document tree, and table cells are inside of rows but not inside of columns.
Thedirection andunicode-bidi properties are the two only properties which are not affected by theall shorthand property.
Syntax
/* Keyword values */direction: ltr;direction: rtl;/* Global values */direction: inherit;direction: initial;direction: unset;Values
ltrText and other elements go from left to right. This is the default value.
rtlText and other elements go from right to left.
For thedirection property to have any effect on inline-level elements, theunicode-bidi property's value must beembed oroverride.
Formal definition
| Начальное значение | ltr |
|---|---|
| Применяется к | все элементы |
| Наследуется | да |
| Обработка значения | как указано |
| Animation type | Not animatable |
Formal syntax
direction =
ltr|
rtl
Examples
>Setting right-to-left direction
blockquote { direction: rtl;}Спецификации
| Specification |
|---|
| CSS Writing Modes Level 4> # direction> |
| Scalable Vector Graphics (SVG) 2> # DirectionProperty> |