html · level 3 · unit 7 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
lang works on any element, and translate="no" protects names.
lang on <html> sets the language for the whole page. When a few words come from another language, put lang on the element around them, like <span lang="fr">bon appétit</span>. Screen readers then switch voice and say them properly.
Browsers offer : one click and the page appears in another language. That is handy, until it turns your café, Bread and Butter, into Pain et Beurre.
Add translate="no" to anything that must stay as written, such as names, product codes and code samples. Everything else still translates.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bread and Butter Café</title>
</head>
<body>
<h1 translate="no">Bread and Butter</h1>
<p>Our motto is <span lang="fr">bon appétit</span>, which means enjoy your meal.</p>
<p>Ask for the <span translate="no">Big Breakfast</span>, our best seller.</p>
</body>
</html> Press show my page to see it here.
Use the same language codes as on <html>, like fr, cy or es.
guess first
A visitor translates this page into Spanish. What happens to the heading?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
<h1 translate="no">Night Owl Books</h1>
<p>Open until midnight, every night.</p>
your turn
Your turn. Mark the Welsh greeting.
The greeting on line 1 is Welsh: give its span the language code cy. Then fill the blank on line 2 so the shop's name is never translated.
Press show my page to see it here.
- the greeting is marked as Welshnot checked yet
- the shop's name stays as writtennot checked yet
fix it
A screen reader says the French in an English voice. Can you fix it?
Press show my page to see it here.
- the dish is marked as Frenchnot checked yet
- The browser does not know this attribute. Is that its real name?
- The attribute for a language is short, the same one you put on
<html>. - Change
language="fr"tolang="fr", then press run.
nailed it
every word speaks its own language. :D
langworks on any element, not only<html>.- Screen readers switch voice for words that are marked.
translate="no"keeps names safe from machine translation.
new words in your collection
- machine translation
This lesson isn’t saved. A free account remembers every lesson you finish.