How to set the direction of text within an HTML element with CSS
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.
Use the text editor below to practice setting the direction of text from either left to right or right to left with CSS.