Here is an example that declares the language to be English. Language for your HTML page suggested its use, and some HTML authoring tools automatically created such elements when you specified language information usingĭialog boxes. The use of a meta element in the document head with the http-equiv attribute set to Content-Language is not mentioned directly in the HTML 4.01 specification, and yet, for a long time, much of the informal guidance out on the Web about how to declare The information in this section is less likely to be useful, but is provided for completeness. The HTTP header should be used only to provide metadata about the intended audience of the document as a whole, and the language attribute on the html tag should be used to declare the default language of the content. However, since you should always use a language attribute on the html tag, and the language attribute always overrides the HTTP header information, this really becomes a fine point. The HTML5 specification says that if there is no lang attribute on the html tag, and if there is no meta element with the http-equiv attribute set to Content-Language, and if there is only a single language tag in the HTTP header declaration, then a browser must use that information to guess at the default language of the text in the page. Even in a browser that does this, however, the information seems to be applied to some features and not others that are affected by language. If no language is declared on the html tag, some, but not all, mainstream browsers recognize the value declared in the HTTP header to set the default language of the text in the page. Inferring the language of the text from an HTTP header If you want to better understand the distinction between (1) usingįile metadata to identify the audience for the document, and (2) specifying the language used for processing content, see the article Types of language declaration.įor more information about how to use the lang attribute, see Declaring language in HTML. You should always use it on the html element tag, and then also use it on any elements that surround fragments of content in a different language. for hyphenation, styling, spell checking, etc). In HTML, the lang attribute should be used to specify the language of text content so that the browser can correctly display or process your content (eg. There is currently no widely recognized way of representing this kind of metadata inside the page. See also Inferring the language of the text from an HTTP header.īecause language information in the HTTP header is sent by the server, this information is simply not available if your page is accessed from a hard drive, memory stick, or other non-server based location. Such metadata may be used for serving the right language version, workflow management, classification, searching, etc. The HTTP Content-Language header can provide useful language data related to the page or resource you are retrieving, but the HTTP specification indicates clearly that the intent of this information is to provide metadata about the intended audience of the document, rather than to indicate the actual language of the text itself. If the server uses information it has about you to automatically select a particular language version ('content negotiation'), the language version selected will be identified in the HTTP header. For example, you will typically find a Content-language header in the HTTP metadata when a server holds more than one version of a resource, each in a different language. The Content-Language header is associated with a particular page by settings on the server or by server-side scripting. Unlike a lang attribute on an HTML element, if your intended audience speaks more than one language, the HTTP header allows you to use a comma-separated list of languages. Here is an example of an HTTP Content-Language header that declares the resource to be a mixture of English, Hindi and Punjabi. Vary: negotiate,accept-language,Accept-Encoding HTTP/1.1 200 OKĬontent-Location: qa-http-and-lang.en.php See the last line in the example below that shows the HTTP response that accompanies this article. ![]() One of the items you may find in such metadata is language related. It uses a format referred to as 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). ![]() To learn about how to use the lang attribute, see Declaring language in HTML. ![]() If you want to know why this approach is deprecated, see below. Instead, you should always use a lang attribute on the html tag to declare the default language of the text in the page. This use of the content-language value for an http-equiv attribute is deprecated by the HTML specification, and should no longer be used.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |