Just as a browser does not assume whether a block of text is a paragraph or a heading, a browser does not necessarily know if the content is written in English or Spanish. And without some more information, neither will search engines, screen readers, or other software.
We can use the lang attribute to specify the language in which the content of the Web page is written. In HTML5, the lang attribute can be used in any element that possesses content. For example, you could make one paragraph in one language, and the next paragraph in another. Each available language can be referenced by a two-letter code, e.g., "en" for English, "jp" for Japanese, "fr" for French, "de" for German, and so on.
For more details about implementing multiple languages in a document, and links to other related resources, including the full list of codes (and dialect codes), visit Penn State University's page about language tags.
Even though there won't be any difference in how this page is rendered by the browser, there are plenty of benefits from being explicit about the language.
Screen readers will process the content more faithfully, and page formatting will behave more as expected by the designer. Search engines can now more properly index the Web page to the appropriate region. For example, a Web page written in French will be found at google.fr.
Since our entire Web page is written in English, we will add the lang attribute to the html element.
Step1. To create the lang attribute for the html element, type:
<!doctype html>
<html lang="en">
Exiting code block
Step2. Save and refresh index.html.