Style direction attribute

Definition and Usage

direction Sets or returns the text direction (reading order) of the element's content.

See also:

CSS Tutorial:Texto CSS

CSS Reference Manual:Direction attribute

HTML Reference Manual:Propriedade dir do HTML

HTML DOM Reference Manual:HTML DOM dir attribute

Example

Example 1

Sets the text direction of the <p> element to 'right to left':

document.getElementById("myP").style.direction = "rtl";

Try It Yourself

Example 2

Returns the text direction of the <p> element:

alert(document.getElementById("myP").style.direction);

Try It Yourself

Syntax

Return the direction attribute:

object.style.direction

Set the direction attribute:

object.style.direction = "ltr|rtl|initial|inherit"

Property Value

Value Description
ltr The text flows from left to right. Default.
rtl The text flows from right to left.
initial Sets this property to its default value. See initial.
inherit Inherits this property from its parent element. See inherit.

Technical Details

Default value: ltr
Return value: A string that represents the text direction of the element.
CSS Version: CSS2

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Suporte Suporte Suporte Suporte Suporte