Revision 1111765 of Content-Language

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

Revision Content

{{HTTPSidebar}}

The Content-Language {{Glossary("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).

Note: Language tags are formaly defined in RFC 5646, which relay 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.

<html lang="de">

Do not use this meta element like this for stating a document language:

<!-- /!\ This is bad practice -->
<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> {{Glossary("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 ("<code>-</code>", <code>%x2D</code>). In most cases, a language tag consists of a primary language subtag that identifies a broad family of related languages (e.g., "<code>en</code>" = English), which is optionally followed by a series of subtags that refine or narrow that language's range (e.g., "<code>en-CA</code>" = the variety of English as communicated in Canada).</dd>
</dl>

<div class="note">
<p><strong>Note:</strong> Language tags are formaly defined in <a href="https://tools.ietf.org/html/rfc5646">RFC 5646</a>, which relay on the <a href="https://en.wikipedia.org/wiki/ISO_639">ISO 639</a> standard (quite often the <a href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes">ISO 639-1 code list</a>) for <a href="https://en.wikipedia.org/wiki/Language_code">language codes</a> to be used.</p>
</div>

<h2 id="Examples">Examples</h2>

<h3 id="Indicating_the_language_a_document_is_written_in">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;!-- /!\ This is bad practice --&gt;
&lt;meta http-equiv="content-language" content="de"&gt;</pre>

<h3 id="Indicating_a_target_audience_for_a_resource">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">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</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