CodeBlanks Logo Icon CodeBlanks

Summary - Multilingual page

HTML course · Expert · Lesson 23/39

Write a bilingual page skeleton with all i18n techniques.

What we learned in this group

In this group you met the internationalization techniques:

  • Declaring page language and direction with lang and dir
  • Introducing sibling pages with hreflang
  • Controlling mixed-direction text with <bdi> and <bdo>
  • Writing RTL-aware tables, forms and landmarks
  • Using canonical and hreflang together

Now we will combine all of these into a bilingual page skeleton.

Exercise Bilingual page skeleton

Write a skeleton for a Turkish home page. Start with <html lang="tr" dir="ltr">. In the <head> add <meta charset="utf-8"> and a <title> (text: Magazine). Also add three <link rel="alternate" hreflang="..."> to the head: hreflang="tr" href="https://magazine.com/tr/", hreflang="en" href="https://magazine.com/en/" and hreflang="x-default" href="https://magazine.com/tr/". In the body add a <header> holding an <h1> (text: Magazine) and a <main>.

Show example solution
<html lang="tr" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Magazine</title>
    <link rel="alternate" hreflang="tr" href="https://magazine.com/tr/">
    <link rel="alternate" hreflang="en" href="https://magazine.com/en/">
    <link rel="alternate" hreflang="x-default" href="https://magazine.com/tr/">
  </head>
  <body>
    <header>
      <h1>Magazine</h1>
    </header>
    <main></main>
  </body>
</html>

Test yourself

  1. Match each tag or attribute

    lang
    Declares language code
    dir
    Declares text direction
    hreflang
    Introduces a sibling page
    bdi
    Wraps unclear-direction text
  2. Complete the Turkish html tag

    <html ____>
      <head></head>
      <body></body>
    </html>
    Show answer
    <html lang="tr" dir="ltr">
      <head></head>
      <body></body>
    </html>
  3. Which attribute declares RTL direction?

    • dir
    • lang
    • charset
    • href
    Show answer

    dir — Correct. The dir attribute declares text direction (ltr/rtl).

All lessons in Expert