---
title: "Declare HTML Language Attribute – How Does it Work?"
description: "Declaration of languages is very important for your content but is also good for Google Search engine. When you create a new domain this helps search engines de"
canonical: "https://www.georanker.com/how-to-declare-encoding-for-your-website-via-html"
last_modified: "2019-04-16T14:15:34"
---

# Declare HTML Language Attribute – How Does it Work?

Published: 2014-06-02. Updated: 2019-04-16. Author: GeoRanker.

> Historical article. Product names, prices, links and third-party behavior may have changed since publication. Use [current products](https://georanker.com/ai/index.md), [pricing](https://georanker.com/ai/pricing.md) and [documentation](https://docs.georanker.com/llms.txt) for current GeoRanker answers.

Declaration of languages is very important for your content but is also good for Google Search engine.

When you create a new domain this helps search engines detect language of your website which is important for your specific region. For general search, English will work the best.

On the other hand, when trying to rank on local Google, you need to use language that is common for that country.

In any case, it is something you need to do before anything else.

## Main things a web user has to know

Besides helping search engines, there are other benefits when you have declared language:

-   It shows the proper font
-   It can be used to convert text to speech (for example, UK English instead of simply English)
-   Documents will be shown in natural language
-   Browser can use it for dictionary

## How to declare HTML language attribute properly?

Language attribute and HTML always go together; HTML element always has to use a language tag which will also be added to other attributes by default.

If there is an article or some other type of content on a page with different language from that which HTML element uses, people have to use attributes on surrounding elements.

Even if you declare HTML language attribute in the right form, you still might encounter issues especially if you have a multi-annual text.

## How to add the right HTML attribute?

For HTML, _lang_ attribute is a must.

Here is how you set code for English language:

In some cases you will require several languages. These are called polyglot pages and they require both _xml:lang_ and _lang_ tags whenever you wish to add a language. You don’t need _xml:lang_ tag when you deal with HTML. However, due to _lang_ part of the attribute, it will still be recognized by various browsers.

## What if attribute values and element use different languages?

One of the best examples for this is when you have a multilingual site. While website may be based on English as the primary language, it also may list some other language. These languages may be shown in their original version that is, by using language’s letters and spelling.  Such small changes will be important for foreigners as may not be able to read link to _languages_. By including this language option in their native tongue, they can recognize it and switch it whenever.

_Deutsch/spam>_

## Things which you can skip

There are certain things that are more of waste of time than anything but I will mention them anyway.

-   Please have in mind that CSS cannot be used for language declaration
-   Doctype may be confusing for some users; you may notice EN tag but this doesn’t refer to language of a document but instead language of schema

-   Character encoding will not allow clear detection of natural language as well as text direction

## Extra Tips for Encoding

Instead of UTF-8, webmasters can use any character set from IANA character sets. However, no browser understands all of them.

It is highly recommended that for a better chance of browser encoding recognition, a more widely character encoding should be used.

## Last thoughts

Language should always be in the centre of attention if you’re running a multilingual site.

With guidelines that I mentioned in previous chapters, there shouldn’t be any issue to declare HTML language attribute properly.

Have you had any issues when declaring languages for your site? How did you resolve them?

[Canonical article](<https://georanker.com/how-to-declare-encoding-for-your-website-via-html>)
