Style direction Property
Example
Set the text direction of a <p> element to "right-to-left":
document.getElementById("myP").style.direction = "rtl";
Try it Yourself »
Definition and Usage
The direction property sets or returns the text direction (reading order) of an element's content.
Browser Support
Property | |||||
---|---|---|---|---|---|
direction | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the direction property:
object.style.direction
Set the direction property:
object.style.direction = "ltr|rtl|initial|inherit"
Property Values
Value | Description |
---|---|
ltr | Text flows from left to right. This is default |
rtl | Text flows from right to left |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Technical Details
Default Value: | ltr |
---|---|
Return Value: | A String, representing the text direction of an element |
CSS Version | CSS2 |
More Examples
Example
Return the text direction of a <p> element:
alert(document.getElementById("myP").style.direction);
Try it Yourself »
Related Pages
CSS tutorial: CSS Text
CSS reference: direction property
HTML reference: HTML dir Attribute
HTML DOM reference: HTML DOM dir Property
❮ Style Object