- Content-Language
- Syntax
- Directives
- Examples
- Indicating the language a document is written in
- Indicating a target audience for a resource
- Specifications
- Browser compatibility
- See also
- Found a content problem with this page?
- MDN
- Support
- Our communities
- Developers
- Описание мета-тегов
- Описание страницы
- Title
- Description
- Keywords
- Кодировка сайта
- Application-Name
- Generator
- Author
- Copyright
- Reply-To
- Content-Language
- Help
- Управление индексацией
- Robots
- Last-Modified
- Document-State
- Revisit-After
- Управление кэшированием
- Cache-Control
- Pragma
- Expires
- Canonical — предпочитаемый канонический адрес
- Prev
- Next
- HTTP headers, meta elements and language information
- The meta element
- HTTP headers
- Document-internal metadata
- Further reading
Content-Language
The Content-Language representation header is used to describe the language(s) intended for the audience, so users can differentiate it according to their own preferred language.
For example, if » Content-Language: de-DE » is set, it says that the document is intended for German language speakers (however, it doesn’t indicate the document is written in German. For example, it might be written in English as part of a language course for German speakers. If you want to indicate which language the document is written in, use the lang attribute instead).
If no Content-Language is specified, the default is that the content is intended for all language audiences. Multiple language tags are also possible, as well as applying the Content-Language header to various media types and not only to textual documents.
Header type | Representation header |
---|---|
Forbidden header name | no |
CORS-safelisted response header | yes |
CORS-safelisted request header | yes, with the additional restriction that values can only be 0-9 , A-Z , a-z , space or *,-.;= . |
Syntax
Content-Language: de-DE Content-Language: en-US Content-Language: de-DE, en-CA
Directives
Multiple language tags are separated by a comma. Each language tag is a sequence of one or more case-insensitive subtags, each separated by a hyphen character (» — «, %x2D ). In most cases, a language tag consists of a primary language subtag that identifies a broad family of related languages (e.g., » en » = English) and is optionally followed by a series of subtags that refine or narrow that language’s range (e.g., » en-CA » = the variety of English as communicated in Canada).
Note: Language tags are formally defined in BCP 47, which rely on the ISO 639 standard (quite often the ISO 639-1 code list) for language codes to be used.
Examples
Indicating the language a document is written in
The global lang attribute is used on HTML elements to indicate the language of an entire HTML document or parts of it.
Do not use this meta element like this for stating a document language:
meta http-equiv="content-language" content="de" />
Indicating a target audience for a resource
The Content-Language header is used to specify the page’s intended audience and can indicate that this is more than one language.
Specifications
Browser compatibility
BCD tables only load in the browser
See also
Found a content problem with this page?
This page was last modified on Apr 11, 2023 by MDN contributors.
Your blueprint for a better internet.
MDN
Support
Our communities
Developers
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998– 2023 by individual mozilla.org contributors. Content available under a Creative Commons license.
Описание мета-тегов
Посмотрев HTML код разных сайтов возникает вопрос – зачем в нем так много мета-тегов и для чего они нужны? В данной статье представлены все самые встречающеюся теги с примерами и пояснениями.
Описание страницы
Title
Заголовок страницы, оптимальная длина 50-60 символов.
Description
Краткое описание страницы длинной 160-180 символов, используется в выводе результатов поиска.
Keywords
Содержит ключевые слова встречающихся на странице. Не более 20-ти слов и 3-х повторов.
Кодировка сайта
Application-Name
Название веб-приложения. Можно указать несколько названий для разных языковых локалей.
- В Android используется при добавлении сайта на главный экран.
- В Windows 8, 10 при добавлении сайта в панель приложений и плиткой в меню пуск.
Generator
Сообщает, с помощью какой программы был сгенерирован код страницы.
Author
Информация об авторе сайта.
Copyright
Информация о владельце сайта.
Reply-To
Указывает способ связи с автором страницы.
Content-Language
Указывает язык страницы. Используется поисковыми машинами при индексировании.
Help
Предоставляет ссылку на справку или e-mail.
Управление индексацией
Robots
Задает правила индексации для поисковых роботов.
Общие значения:
index , follow или all | Разрешено индексировать текст и ссылки на странице |
noindex | Не индексировать текст страницы |
nofollow | Не переходить по ссылкам на странице |
noindex , nofollow или none | Запрещено индексировать текст и переходить по ссылкам |
noarchive | Не показывать ссылку на сохраненную копию в поисковой выдаче |
noyaca | Не использовать описание из Яндекс.Каталога для сниппета в результатах поиска |
nosnippet | Запрещает показывать видео или фрагмент текста в результатах поиска |
noimageindex | Запрещает указывать вашу страницу как источник ссылки для изображения |
noodp | Не использовать описание из каталога DMOZ |
Last-Modified
Альтернативно HTTP-заголовку Last-Modified задает дату последнего изменения для статических страниц.
Document-State
Определяет частоту индексации для поисковых роботов.
Revisit-After
Указывает как часто обновляется информация на сайте, и как часто поисковая система должна на него заходить.
Управление кэшированием
Cache-Control
Указывает как браузеру кэшировать страницу.
Допустимые значения:
public | Кэшируется все |
private | Кэшируется браузером, но не proxy-сервером |
no-cache | Запрещает кэширование |
max-age=0 | Сколько секунд хранить в кэше |
Pragma
Expires
Дата окончания кэша браузера. Если указать прошедшую дату или 0, то документ не будет кэшироваться.
Canonical — предпочитаемый канонический адрес
Если у страницы есть дубликаты с одним содержанием и разными URL, например:
В rel=»canonical» указывается адрес, который будет считаться основным и будет использоваться в поисковой выдаче.
Prev
Указывает URL предыдущий страницы при пагинации.
Next
Указывает URL следующий страницы при пагинации.
HTTP headers, meta elements and language information
In addition to the lang (and/or xml:lang) attribute on the html tag, you may come across language information in HTML meta elements, or in the HTTP header which is served with an HTML page. Here we look at whether these are useful when declaring language for HTML content, and if so, how they should be used.
This article is (specifically) about language declarations in HTTP headers and meta elements. It’s not a general guide to setting language on an HTML page: for that, see Declaring language in HTML .
This article builds on the distinction between (1) using file metadata to identify the audience for the document, and (2) specifying the language used for the purpose of processing content. If you want to better understand the distinction see the article Types of language declaration.
The meta element
You may come across a language-related meta element near the top of an HTML file. It looks like this.
This use of the content-language value for an http-equiv attribute is deprecated by the HTML specification, and should no longer be used. Instead, you should always use a lang attribute on the html tag to declare the default language of the text in the page.
If you want to know why this approach is deprecated, see below. To learn about how to use the lang attribute, see Declaring language in HTML.
HTTP headers
When you retrieve a web page or resource from a server, the server sends with it various bits of information about the thing you are retrieving (metadata). It uses a format referred to as HTTP headers. One of the items you may find in such metadata is language related. See the last line in the example below that shows the HTTP response that accompanies this article.
Unlike the lang and xml:lang attributes, the value of the content attribute can be a comma-separated list of language tags. The example below declares the primary languages of the document to be (in equal measure) German, French and Italian.
If the name of the meta element wasn’t a clear enough clue, the fact that the value supports multiple languages indicates that this element is really about document level metadata. If you are to usefully indicate the language of a range of text, you have to be specific – it can only be in one language at a time. The meta element, then, is an in-document location for expressing metadata about the language of the intended audience of the document as a whole.
Until recently, few browsers paid any attention to this meta element. Then several major browsers began using this element, if there was no language attribute on the html tag, to set the default language of the text in the document (what you should use a language attribute on the html tag for). The way this was implemented was inconsistent, and therefore unreliable, from one browser to another.
Because of the history of confusion and inconsistent implementation surrounding this kind of declaration, in 2011 the HTML Working Group took a decision to make the meta element with http-equiv set to Content-Language non-conforming in HTML. This means that you should no longer use it in HTML5, and therefore, though technically not illegal in other types of HTML, it is best to now not use it anywhere.
HTML5 did, however, make a concession for backwards compatibility. If there is a meta element with http-equiv set to Content-Language in the markup, and if there is no language attribute on the html tag, and if the meta element has a value that is a single language tag, then a browser must use that information to guess at the default language of the text on the page. Having said that, this is only for backwards compatibility, and you really shouldn’t use this approach any more. Simply use a language attribute on the html tag.
Document-internal metadata
One implication of HTML5 dropping the meta element for declaring language is that there is now no obvious way to provide metadata about the document inside the document itself. In theory it would be quite useful for content management systems, translation processes, and the like. This kind of information can be carried by an HTTP header (as we’ll see in the next section), but such systems and processes tend to work on documents that are not sent from a server with an HTTP header, and so in-document metadata would be useful.
Perhaps another approach, such as RDFa, would provide a way of representing such information in the future.
The WHATWG Wiki MetaExtensions page provides an extended list of values that could be used with the meta element’s name value, though none have been formally accepted yet. One such value is dc.language , used to express language information with Dublin Core notation.
It is unclear, however, that this information is ever used by browsers, or to what extent it is used by any other application. The WHATWG page recommends that the lang attribute be used instead. That recommendation is good for declaring the text-processing language, but doesn’t address its possible use for expressing metadata about the page as a whole.