Style direction attribute
- 上一页 cursor
- 下一页 display
- 返回上一层 HTML DOM Style Object
Definition and Usage
direction
Sets or returns the text direction (reading order) of the element content.
See also:
CSS Tutorial:CSS 文本
CSS Reference Manual:Direction attribute
HTML Reference Manual:HTML dir 属性
HTML DOM Reference Manual:HTML DOM dir attribute
Instance
Example 1
Set the text direction of the <p> element to "from right to left":
document.getElementById("myP").style.direction = "rtl";
Example 2
Return the text direction of the <p> element:
alert(document.getElementById("myP").style.direction);
Syntax
Return direction attribute:
object.style.direction
Set direction attribute:
object.style.direction = "ltr|rtl|initial|inherit"
Attribute Value
Value | Description |
---|---|
ltr | Text flows from left to right. Default. |
rtl | Text flows from right to left. |
initial | Sets this property to its default value. See initial。 |
inherit | Inherits this property from its parent element. See inherit。 |
Technical Details
Default value: | ltr |
---|---|
Return value: | String that represents the text direction of the element. |
CSS Version: | CSS2 |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
支持 | 支持 | 支持 | 支持 | 支持 |
- 上一页 cursor
- 下一页 display
- 返回上一层 HTML DOM Style Object