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

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


To display text Right-to-Light (rtl) in HTML, use the CSS property direction. Use it with the style attribute. The style attribute specifies an inline style for an element.

You can use the following property values to set direction with the CSS property direction −

Sr.No.Value & Description
1ltr
Writing direction from left to right
2rtl
Writing direction from right to left
3initial
initial

Use the style attribute with the CSS property direction to display text Right-to-Left. Just keep in mind, the usage of style attribute overrides any style set globally. It will override any style set in the HTML <style> tag or external style sheet.

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

Example

You can try to run the following code to display text right-to-left using HTML

<!DOCTYPE html>
<html>
<head>
<title>HTML Text Direction</title>
</head>

<body>
   <p style = "direction: rtl;">
      Displayed from right to left
   </p>
</body>
</html>