When developing multilingual websites, it is crucial to specify the language of the content using appropriate language codes. HTML provides a standard set of ISO language codes that allow you to indicate the language of your web page or specific content within it. In this post, we will explore the HTML language ISO codes reference to help you effectively communicate the language of your web content.
<strong>lang</strong> attribute is used to specify the language of an HTML element or the entire web page. It is typically added to the opening <html> tag. The language code should follow the ISO 639-1 or ISO 639-2 standard.
In the above example,
en represents English as the language of the web page.
To specify the language of specific content within your HTML document, you can use the
lang attribute on individual elements. This is particularly useful when you have content in different languages on the same page.
<p lang="fr">Ceci est un paragraphe en français.</p> <p lang="es">Este es un párrafo en español.</p>
In the above example, the first paragraph is in French (
fr), while the second paragraph is in Spanish (
In some cases, you may need to indicate language variants or regional variations within a language. ISO 639-1 does not cover all language variants, but ISO 639-2 and ISO 639-3 provide more extensive coverage.
<p lang="zh-Hans">这是简体中文。</p> <p lang="zh-Hant">這是繁體中文。</p>
In the above example, the first paragraph is in Simplified Chinese (
zh-Hans), while the second paragraph is in Traditional Chinese (
Language and SEO
Specifying the language of your web content using ISO codes is not only important for user experience but also for search engine optimization (SEO). Search engines rely on language information to understand and serve relevant results to users.
By indicating the correct language, you can improve the visibility and searchability of your content in the respective language-specific search results.
<!DOCTYPE html> <html lang="de"> <head> <meta charset="UTF-8"> <title>Meine Webseite</title> </head> <body> <h1>Willkommen auf meiner Webseite</h1> <p lang="de">Dies ist ein Beispieltext auf Deutsch.</p> <p lang="en">This is an example text in English.</p> </body> </html>
In the above example, the web page is in German (
de). The first paragraph is in German, while the second paragraph is in English.
By utilizing the HTML language ISO codes correctly, you ensure that your content is correctly identified and understood by both users and search engines, facilitating better accessibility and discoverability.
Remember to choose the appropriate ISO code that corresponds to the language of your content.