HTML dir Attribute


The dir attribute in HTML is used to set the direction of content in an element.

Let us now see an example to implement the dir attribute in HTML −

Example

 Live Demo

<!DOCTYPE html>
<html>
<body>
   <h2>Demo Heading</h2>
   <p>This is normal text.</p>
   <p dir="rtl">This text would get displayed from left to right.</p>
</body>
</html>

Output

In the above example, we have first set the normal text − 

<p>This is normal text.</p>

After that, we have also displayed a text with direction left to right using the dir attribute −

<p dir="rtl">This text would get displayed from left to right.</p>

Updated on: 29-Jun-2020

96 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements