HTML hreflang Attribute

HTML hreflang Attribute: It can be defined as the language of the linked source. This attribute can be applied to <a>,<area>,<link> elements. This attribute is only used if the href attribute is present in the element.

HTML hreflang Attribute

This attribute is purely advisory.

Syntax: <a hreflang=”language_code”>

Browser Support:



This attribute is supported by the following browsers:

  • Chrome
  • Firefox
  • Internet Explorer
  • Safari
  • Opera

 Example: using <a> element

<!DOCTYPE html>
<html>
<body>
<p><a hreflang="en" href="https://tutorials.freshersnow.com/">Freshersnow Tutorilas</a></p>
</body>
</html>

Output:

HTML hreflang attribute

Example: for using <area> element

<!DOCTYPE html>
<html>
<body>
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm" hreflang="en">
</map>
</body>
</html>

Output:

HTML area element

 

Example: for using <link> element

<html>
<head>
  <link href="tag_link.asp" rel="parent" rev="subsection" hreflang="en">
</head>
<body>
<p>Freshersnow</p>
<p>The hreflang attribute does not render as anything special in any of the major browsers. It can be used by search engines or in scripts.</p>
</body>
</html>

Output:

freshersnow example page.

The hreflang attribute does not render as anything special in any of the major browsers. However, it can be used by search engines, or in scripts.