CSS Direction Property



CSS Tutorial  >  Text  >  Direction

The direction property specifies the text direction. Possible values are as follows:

  • ltr: left to right. This is the default value.
  • rtl: right to left. This is used for web pages using a language that goes from right to left, such as Hebrew, Syriac, or Arabic.

Note that there is an HTML attribute, dir, that also sets the direction of the text. The values this attribute takes are the same as that for the CSS direction property. Its syntax is as follows:

<body dir="ltr"> or <body dir="rtl">

Below we show examples of the CSS direction property:

Example 1: Left to right

CSS Declaration

p {
  direction: ltr;
}

The following HTML,

<p>Left to right.</p>

renders

Left to right.

Example 2: Right to left

CSS Declaration

p {
  direction: rtl;
}

The following HTML,

<p>من اليمين الى اليسار</p>

renders

أمن اليمين الى اليسار

Next: CSS Letter-Spacing




Copyright © 2017   1keydata.com   All Rights Reserved   Privacy Policy   About   Contact