THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Style direction Property

Style Object Reference Style Object

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

Internet Explorer Firefox Opera Google Chrome Safari

The direction property is supported in all major browsers.


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