html · level 3 · unit 7 · lesson 2
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
dir="rtl" turns the page round for languages.
English runs left to right. Arabic, Hebrew, Persian and Urdu are right-to-left: each line starts at the right-hand edge. changes the whole page, not only the letters. Lists, tables and forms all flip round.
For a whole page, set dir="rtl" on <html>, next to lang. For one part in another direction, put dir on that element instead.
Never fake it by lining text up on the right. dir tells the browser, screen readers and search engines how the text really reads.
<!doctype html>
<html lang="ar" dir="rtl">
<head>
<meta charset="utf-8">
<title>مخبز الياسمين</title>
</head>
<body>
<h1>مخبز الياسمين</h1>
<ul>
<li>خبز</li>
<li>كعك</li>
</ul>
</body>
</html> Press show my page to see it here.
Run it and look at the list: the bullets sit on the right.
guess first
Where will the bullets sit?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
<ul lang="he" dir="rtl">
<li>שלום</li>
<li>תודה</li>
</ul>
your turn
Your turn. Turn the page round.
This page is in Arabic. On line 2, set the language code to ar and the direction to right-to-left.
Press show my page to see it here.
- the page says it is Arabicnot checked yet
- the text runs right to leftnot checked yet
fix it
The Hebrew runs the wrong way. Can you fix it?
Press show my page to see it here.
- the Hebrew runs right to leftnot checked yet
diruses the valuertlnot checked yet
dironly understands a few short values. Is right one of them?- The value for right-to-left is three letters: r, t and l.
- Change
dir="right"todir="rtl"on line 2, then press run.
nailed it
your page reads both ways. :D
- Arabic and Hebrew are right-to-left languages.
dir="rtl"goes on<html>withlang, or on one element.- Use
dir, never fake it by lining text up.
new words in your collection
- text direction
- right-to-left
This lesson isn’t saved. A free account remembers every lesson you finish.