Style direction Property

Style Object Reference Style Object


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

Internet Explorer Firefox Opera Google Chrome Safari

The direction property is supported in all major browsers.


Return the direction property:

Set the direction property:"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


Return the text direction of a <p> element:


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 Reference Style Object


Color Picker