CSS direction attribute

Definition and Usage

The direction attribute specifies the text direction / writing direction.

This attribute specifies the basic block writing direction, as well as the embedding and override directions for the Unicode bidirectional algorithm. User agents that do not support bidirectional text can ignore this attribute.

See Also:

CSS Tutorial:CSS Text

HTML DOM Reference Manual:direction Attribute

Example

Set the text direction to 'right to left':

div
  {
  direction: rtl;
  }

Try It Yourself

CSS Syntax

direction: ltr|rtl|initial|inherit;

Attribute Value

Value Description
ltr Default. Text direction is from left to right.
rtl Text direction is from right to left.
inherit Specify that the direction attribute value should be inherited from the parent element.

More Examples

Set Text Direction
This example demonstrates how to set the text direction.

Technical Details

Default Value: ltr
Inheritance: yes
Version: CSS2
JavaScript Syntax: object.style.direction="rtl"

Browser Support

The numbers in the table indicate the first browser version that fully supports this attribute.

Chrome IE / Edge Firefox Safari Opera
2.0 5.5 1.0 1.3 9.2