Open In App

CSS direction Property

 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:  

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

<!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: 

Article Tags :