Open In App

CSS direction Property

Last Updated : 26 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

 The direction property in CSS is all about setting the text direction within any block element. It offers two values: rtl (right to left) and ltr (left to right), giving you control over the flow of your text.

Syntax:  

element_selector {
direction: rtl|ltr|initial|inherit;
}

Default Value: ltr 

Property values:  

  • rtl: Specifies the direction as the right to left.
  • ltr(default): Specifies the direction as left to right which is also the default direction.
  • initial: Sets the property to its default value.
  • inherit: Inherits the property from the parent element.

Example: In this example, we are using the above-explained property.

html
<!DOCTYPE html>
<html>
<head>
    <title>
        CSS | direction Property
    </title>
    <style>
        html {
            color: green;
        }

        .rtl {
            direction: rtl;
        }

        .ltr {
            direction: ltr;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>
    <p>This text goes from left to right. This is default.</p>
    <p class="ltr">This text goes from left to right.</p>
    <p class="rtl">This text goes from right to left.</p>
</body>
</html>

Output: 

Supported Browsers: The browsers supported by direction property are listed below: 

  • Google Chrome 2.0
  • Edge 12.0
  • Internet Explorer 5.5
  • Firefox 1.0
  • Opera 9.2
  • Apple Safari 1.0

Similar Reads