- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set text direction in 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 using CSS property.
Below syntax set the text to right-to-left direction.
<p style = "direction: rtl;">The text…</p>
Example
Following is the example program to set text direction in HTML.
<!DOCTYPE html> <html> <head> </head> <body> <p style = "direction: rtl;"> Delhi Land and Finance is one of the largest commercial real estate developer in India. </p> </body> </html>
Text direction as left to right using CSS
We can set the direction of the text to right by using the below syntax.
Syntax
Following is the syntax to set text direction using CSS property.
Below syntax set the text to left-to-right direction.
<p style = "direction: ltr;">The text…</p>
Example
Following is the example program to set text direction in HTML.
<!DOCTYPE html> <html> <head> </head> <body> <p style = "direction: ltr;"> Delhi Land and Finance is one of the largest commercial real estate developer in India. </p> </body> </html>
Text direction as auto using CSS
We can set the direction of the text as auto by using the below syntax.
Syntax
Following is the syntax to set text direction using CSS property, browser figure out the text direction, based on the content direction on the web page.
<p style = "direction: auto;">The text…</p>
Example
Following is the example program to set text direction in HTML.
<!DOCTYPE html> <html> <head> </head> <body> <p style = "direction: auto;"> Delhi Land and Finance is one of the largest commercial real estate developer in India. </p> </body> </html>
Example
Following is the example program to set text direction in HTML using internal style sheet.
<!DOCTYPE html> <html> <head> <style> p.id { direction: rtl; } </style> </head> <body> <p class="id"> DLF stands for Delhi Land and FinanceDelhi Land and Finance is one of the largest commercial real estate developer in India. </p> </body> </html>