Skip to: content, navigation

by Ian Lloyd

hreflang (HTML attribute)

Spec
Depr. Version
No HTML 4
Browser support full matrix
IE7 FF2 Saf3 Op9.5
None None None None
hreflang="ISO language code"

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>

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.

Value

This attribute takes a two-letter language code as its value.

Compatibility

IE5.5None
6.0None
7.0None
Firefox1.0None
1.5None
2.0None
Safari1.3None
2.0None
3.0None
Opera9.2None
9.5None

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 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.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters