HTML DOM Style direction Property
Definition and Usage
The direction property sets or returns the text direction of an element.
Syntax
Set the direction property:
Object.style.direction="ltr|rtl|inherit"
Return the direction property:
Object.style.direction
| Value | Description |
|---|---|
| ltr | Default. Text flows from left to right. |
| rtl | Text flows from right to left. |
| inherit | Text direction is inherited from the parent element. |
Browser Support
The direction property is supported by all major browsers.
Note: IE7 and earlier versions do not support the "inherit" value. IE8 only supports "inherit" if a !DOCTYPE is specified. IE9 supports "inherit".
Example
Example
Set the text flow from right to left:
function displayResult(){ document.getElementById("p1").style.direction="rtl"; }This is some text.
YouTip