Title and language
Learn what the <title> element and lang attribute do.
The title element
The <title> tag is the page's title. It appears in the browser tab and in search results. It goes inside <head>; it is shown in the browser bar, not on the page.
Writing a unique, short and descriptive title for each page is a good habit. A good title helps both the user and search engines. Avoid very long titles.
The lang attribute
The <html lang="en"> attribute declares the page's language. Browsers, search engines and screen readers use this info. Use en for English, tr for Turkish.
The right language code helps accessibility and correct spell checking. Language codes are two letters by ISO standard; lowercase is preferred over uppercase.
Exercise Add title and lang
Add the lang="en" attribute and a <title>My Site</title> element inside <head> to the given skeleton.
Show example solution
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Site</title>
</head>
<body>
</body>
</html>
Test yourself
-
What is the <title> tag used for?
- To declare the page's language
- To set the character encoding
- To scale the mobile view
- To set the tab title
Show answer
To set the tab title — Correct. The <title> tag sets the tab title.
-
Add the lang attribute
<html ____> <head></head> <body></body> </html>Show answer
<html lang="en"> <head></head> <body></body> </html> -
Match each tag to its role
- <title>
- Tab title
- lang
- Page language
- <head>
- Page information
- <body>
- Visible content