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>

Updated on: 03-Mar-2020

122 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements