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

How do we set the text direction for the content in an element in HTML?


Use the dir attribute in HTML, to set the text direction for the content in an element. You can try to run the following code to implement dir attribute −

Example

<!DOCTYPE html>
<html>
   <body>
      <p>This is demo text from left-to-right.</p>
      <p dir = "rtl">This is demo text from right-to-left.</p>
   </body>
</html>