HTML hreflang attribute
hreflang
The purpose of the HTML hreflang attribute is to specify the language of the resource linked to by the href attribute of the element.
Supported elements
HTML hreflang attribute supports a and link elements.
Syntax
<ElementName href="link" hreflang="value" >.....</ElementName>
Where ElementName is any supported elements.
Type of value
Language code.
Value
A language code.
Default value
There is no default value of HTML hreflang attribute.
Supported doctypes
HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.
Example of HTML hreflang attribute with a
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML hreflang attribute with a</title>
</head>
<body>
<a href="http://www.bbc.co.uk/bengali/" hreflang="bn" >BBC Bangla </a>
</body>
</html>
Result
View this example in a separate browser window
Example of HTML hreflang attribute with a
Example of HTML hreflang attribute with link
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML hreflang attribute with link</title>
<link rel="index" href="https://www.w3resource.com/index.php" hreflang="en" />
</head>
<body>
<p>This is an example of HTML link element with hreflang attribute.</p>
</body>
</html>
Result
View this example in a separate browser window
Example of HTML hreflang attribute with link
Previous: HTML href attribute
Next: HTML http-equiv attribute
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/html/attributes/html-hreflang-attribute.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics