Revision 1090655 of Content-Language

  • Revision slug: Web/HTTP/Headers/Content-Language
  • Revision title: Content-Language
  • Revision id: 1090655
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment

Revision Content

{{HTTPSidebar}}

The Content-Language entity header is used to describe the language(s) intended for the audience, so that it allows a user to differentiate according to the users' 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 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 {{Glossary("Entity header")}}
{{Glossary("Forbidden header name")}} no

Syntax

Content-Language: de-DE
Content-Language: en-US
Content-Language: de-DE, en-CA

Directives

language-tag
Multiple language tags are separated by 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), which 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).

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.

<html lang="de">

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 intended audience of the page, and can indicate that this is more than one language.

Content-Language: de, en

Specifications

Specification Title
{{RFC("7231", "Content-Language", "3.1.3.2")}} Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content

Browser compatibility

{{Compat}}

See also

Revision Source

<div>{{HTTPSidebar}}</div>

<p>The <strong><code>Content-Language</code></strong> entity header is used to describe the language(s) intended for the audience, so that it allows a user to differentiate according to the users' own preferred language.</p>

<p>For example, if "<code>Content-Language: de-DE</code>" 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).</p>

<p>If no <code>Content-Language</code> 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 <code>Content-Language</code> header to various media types and not only to textual documents.</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Header type</th>
   <td>{{Glossary("Entity header")}}</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Forbidden header name")}}</th>
   <td>no</td>
  </tr>
 </tbody>
</table>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">
Content-Language: de-DE
Content-Language: en-US
Content-Language: de-DE, en-CA
</pre>

<h2 id="Directives">Directives</h2>

<dl>
 <dt><code>language-tag</code></dt>
 <dd>Multiple language tags are separated by 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), which 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).</dd>
</dl>

<h2>Examples</h2>

<h3>Indicating the language a document is written in</h3>

<p>The global <code><a href="/en-US/docs/Web/HTML/Global_attributes/lang">lang</a></code> attribute is used on HTML elements to indicate the language of an entire <a href="/en-US/docs/Web/HTML">HTML</a> document or parts of it.</p>

<pre class="brush: html">
&lt;html lang="de"&gt;</pre>

<p>Do <strong>not</strong> use this meta element like this for stating a document language:</p>

<pre class="brush: html example-bad">
&lt;meta http-equiv="content-language" content="de"&gt;</pre>

<h3>Indicating a target audience for a resource</h3>

<p>The <code>Content-Language</code> header is used to specify the <strong> intended audience of the page</strong>, and can indicate that this is more than one language.</p>

<pre>
Content-Language: de, en</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Title</th>
  </tr>
  <tr>
   <td>{{RFC("7231", "Content-Language", "3.1.3.2")}}</td>
   <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p class="hidden">To contribute to this compatibility data, please write a pull request against this file: <a href="https://github.com/mdn/browser-compat-data/blob/master/http/headers.json">https://github.com/mdn/browser-compat-data/blob/master/http/headers.json</a>.</p>

<p>{{Compat}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{HTTPHeader("Accept-Language")}}</li>
 <li>
  <p><a href="https://www.w3.org/International/questions/qa-http-and-lang.en">HTTP headers, meta elements and language information</a></p>
 </li>
</ul>
Revert to this revision