What is the CSS direction property?

The direction property in CSSCascade Style Sheets specifies the text’s direction within a specified block element.

Syntax


direction: ltr|rtl|initial|inherit;

Property values

  • ltr: ltr means left to right. It is the default value. It moves the text from left to right.

  • rtl: rtl means right to left. It moves the text from right to left.

  • initial: sets the value to its default value.

  • inherit: inherits the property from its parent value.

Code

The basic HTMLHyperText Markup Language and CSS code to demonstrate the use of the direction property is as follows:

Explanation

In this example, we write a code with the open and close quote property. We set the direction of the text from right to left. We can also set the direction of the text from left to right.