CSS Text Direction in HTML Property Syntax and Code Example

CSS Text Direction Property

CSS Text Direction property is used to specify that from which direction the text will be written means from left to right or right to left.

Mostly CSS direction property is used where the language which is written from the right-side direction.

Example 1 – Direction property application and use for h2 HTML element

<!DOCTYPE html>
<html>
  <head>
	<style>
	  .direction
	  {
	   direction: rtl;
	  }
	</style>
  </head>
  
  <body>
	<h1>Text Direction Example</h1>
	<h2>Elex Tutorial - Best Learning Experience</h2>
	<h2 class="direction">Elex Tutorial - Best Learning Experience.</h2>
  </body>
</html>

The above code shows how can you use the direction property.

CSS Text Direction
Fig.1 – CSS Text Direction property syntax and use with h2 tag

Caution:You have to apply direction property with CSS Property unicode-bidi to work correctly.

HTML Text Direction Property Example Code

Text Direction property another example with unicode-bidi property.

Example 2 – Direction property syntax example with unicode-bidi

<!DOCTYPE html>
<html>
  <head>
	<style>
	  .direction
	  {
	   direction: rtl;
	   unicode-bidi: bidi-override;
	  }
	</style>
  </head>
  
  <body>
	<h1>Text Direction Example</h1>
	<h2>Elex Tutorial - Best Learning Experience</h2>
	<h2 class="direction">Elex Tutorial - Best Learning Experience.</h2>
  </body>
</html>

The above code shows how can you use the direction property with unicode-bidi: bidi-override; property.

HTML Text Direction property code example with unicode-bidi property
Fig.2 – HTML Text Direction property code example with unicode-bidi property
You can leave a response, or trackback from your own site.

One Response to “CSS Text Direction in HTML Property Syntax and Code Example”

  1. Thanks on your marvelous posting! I seriously enjoyed reading it, you happen to be a great author.I will remember to bookmark your blog and will come back at some point. I want to encourage one to continue your great posts, have a nice holiday weekend!|

Leave a Reply to the article


Learn CSS

Learning & Certifications
Follow Us
Facebook Icon   Linked In Icon   Twitter Icon  
Validation and Recognition

Valid CSS! Valid HTML5!          Protected by Copyscape