Web Development Tutorials.com

How to set the direction of text within an HTML element with CSS


Click Here for CoffeeCup Website Design Software   GoDaddy.com Hosting & Servers

The below HTML and CSS code example shows you how to set the direction of text within an HTML element from either left to right or right to left with CSS.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>this is the title of the web page</title>

<style type="text/css">

div.one
{
direction: rtl;
}
div.two
{
direction: ltr;
}

</style>

</head>
<body>

<div class="one">
A B C D E
</div>
<div class="two">
F G H I J
</div>

</body>
</html>

The above HTML and CSS code makes the 2 sets of text below.

A B C D E
F G H I J

Use the text editor below to practice setting the direction of text from either left to right or right to left with CSS.