Skip to content

Content-Language

Description

The Content-Language response header is used to describe the language(s) intended for the audience of the response content. This header helps browsers and other user agents determine the language of the content, which can be useful for accessibility features, language-specific formatting, and content selection based on user preferences.

The Content-Language header provides metadata about the linguistic context of the content, enabling browsers to make appropriate decisions about how to present or process the information. For instance, screen readers can use this information to adjust pronunciation, and browsers can apply language-specific typographic rules.

It's important to note that this header indicates the intended audience's language, not necessarily the language of all text within the document. For multi-language documents, the most appropriate value is the primary language of the content or the language intended for the target audience.

Syntax

The syntax of the Content-Language header follows this structure:

Content-Language: <language-tag>[, <language-tag>]*
  • <language-tag>: A language tag as defined by BCP 47 (e.g., en for English, fr for French).
  • Multiple language tags can be specified, separated by commas, when the content is intended for multiple language audiences.

Example Syntax

Content-Language: en-US

This example indicates that the content is intended for an American English-speaking audience.

Content-Language: de, en

This indicates that the content is intended for both German and English-speaking audiences.

Examples

Basic Example

A response with English content:

HTTP/1.1 200 OK
Date: Mon, 02 Jun 2025 17:00:00 GMT
Content-Type: text/html
Content-Language: en
Content-Length: 1234

<!DOCTYPE html>
<html lang="en">
<head><title>English Content</title></head>
<body>This page is in English.</body>
</html>

Note that the HTML lang attribute is also set to match the Content-Language header, which is a good practice for consistency.

Multilingual Example

A response intended for multiple language audiences:

HTTP/1.1 200 OK
Date: Mon, 02 Jun 2025 17:10:30 GMT
Content-Type: text/html
Content-Language: en, es
Content-Length: 2345

<!DOCTYPE html>
<html>
<head><title>Multilingual Content / Contenido Multilingüe</title></head>
<body>
  <div lang="en">This section is in English.</div>
  <div lang="es">Esta sección está en español.</div>
</body>
</html>

In this example, the content contains sections in both English and Spanish, and the Content-Language header reflects that the page is intended for speakers of both languages.

API Response Example

A JSON API response with language-specific content:

HTTP/1.1 200 OK
Date: Mon, 02 Jun 2025 17:20:45 GMT
Content-Type: application/json
Content-Language: fr
Content-Length: 78

{
  "message": "Bonjour, monde!",
  "description": "Un message de bienvenue"
}

This response indicates that the JSON content is in French.

Summary

The Content-Language response header provides valuable metadata about the linguistic context of web content, helping browsers and other user agents present information appropriately based on language. By accurately specifying the intended audience language, content providers can improve accessibility, enable language-specific features, and support multilingual users. While this header does not directly affect how content is rendered, it plays an important role in the overall user experience by providing essential language information to user agents.