How to display text Right-to-Left Using HTML?


The direction property specifies the text direction within a block element on the web page.

We use the style attribute, to set text direction in HTML. The style attribute specifies an inline style for an element within a block. The style attribute is used with the CSS property direction to set direction for the text.

Syntax

Following is the syntax to set text direction (right-to-left) using CSS property.

<p style = "direction: rtl;">The text…</p>

Example

Following is the example program to set direction to the <p> element in HTML.

<!DOCTYPE html> <html> <head> </head> <body> <p style = "direction: rtl;"> whiteboards are so often at the core of a collaborative process </p> </body> </html>

Example

Following is the example program to set direction to the <h2> element in HTML.

<!DOCTYPE html> <html> <head> </head> <body> <h2 style = "direction: rtl;"> Hallowen season it is... </h2> </body> </html>

Example

Following is the example program to set direction to the <ul> element in HTML.

<!DOCTYPE html> <html> <head> </head> <body> <ul style = "direction: rtl;"> <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ul> </body> </html>

Updated on: 11-Nov-2022

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements