Style direction attribute

Definition and usage

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

See also:

CSS tutorial:CSS κείμενο

CSS reference manual:Direction attribute

HTML reference manual:HTML dir ιδιότητα

HTML DOM reference manual:HTML DOM dir attribute

Instance

Example 1

Set the text direction of the <p> element to "from right to left":

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

Try it yourself

Example 2

Return 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"

Attribute value

Value Description
ltr Text flows from left to right. Default.
rtl 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 supports

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Υποστήριξη Υποστήριξη Υποστήριξη Υποστήριξη Υποστήριξη