hreflang (HTML attribute)
| Depr. | Version |
|---|---|
| No | HTML 4 |
| IE8 | FF2 | SA4 | OP10 | CH2 |
|---|---|---|---|---|
| None | None | None | None | None |
Syntax
Description
The
hreflang attribute is used to identify the language
of text used in the linked document—the document that’s referenced in the
href attribute. It’s not used to identify
the language of the text contained within the a element
itself—that would use the lang attribute.
Example
A
hreflang is defined in this link to the cakes list
page, as they’re special Japanese cakes:
<a href="cakes-ja.html" charset="euc-jp" hreflang="ja">lovely range
of Japanese cakes (note: this link will take you to a page in
Japanese language)</a>
Value
This attribute takes a two-letter language code as its value.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | Chrome | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| None | None | None | None | None | None | None | None | None | None | None | None | None | None | None |
None of the browsers tested appear to do anything to notify the user that the linked document would display in any special or different language. However, authors may still be able to use this attribute for their own purposes, as a hook for styling or scripting. For example, you might use CSS (with attribute selector) to style such links with flag icons to represent the particular language used in the destination file.
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.