Computer >> Computer tutorials >  >> Programming >> HTML

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

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

HTML dir Attribute

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>