Style direction attribute
- Previous Page cursor
- Next Page display
- Go to the Previous Level HTML DOM Style Object
Definition and usage
direction
Sets or returns the text direction (reading order) of the element's content.
See also:
CSS Tutorial:CSS Text
CSS Reference Manual:direction attribute
HTML Reference Manual:HTML dir Attribute
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 the direction attribute:
object.style.direction
Set the direction attribute:
object.style.direction = "ltr|rtl|initial|inherit"
Property value
Value | Description |
---|---|
ltr | Text flows from left to right. Default. |
rtl | Text flows from right to left. |
initial | Set this property to its default value. See initial. |
inherit | Inherit this property from its parent element. See inherit. |
Technical details
Default value: | ltr |
---|---|
Return value: | A string representing the text direction of the element. |
CSS Version: | CSS2 |
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page cursor
- Next Page display
- Go to the Previous Level HTML DOM Style Object