This is not a SEO question.
I am curious how to markup HTML in a semantic correct way concerning the used language. Please correct me if my markup is mistaken.
My questions is: do I need the lang
attribute in the html
tag when I already use the hreflang
attribute in the link
tag?
Are both directives semantically different? I mean: will the self-reference in the link
tag in both examples semantically be understood as indicating the language of the document?
The code samples below might clarify my question a bit:
Example of an English webpage
http://example.com/en/
<!DOCTYPE html>
<html lang="en">
<head>
<title>English webpage</title>
<link rel="canonical" href="http://example.com/en">
<link rel="alternate" href="http://example.com/en/" hreflang="en">
<link rel="alternate" href="http://example.com/nl/" hreflang="nl">
<link rel="alternate" href="http://example.com/en/" hreflang="x-default">
</head>
<body>
<p>This is a webpage written in English.
This page is also available in Dutch.
The default language of this page is English.
</body>
</html>
Example of a Dutch webpage
http://example.com/nl/
<!DOCTYPE html>
<html lang="nl">
<head>
<title>Nederlandse webpagina</title>
<link rel="canonical" href="http://example.com/nl">
<link rel="alternate" href="http://example.com/en/" hreflang="en">
<link rel="alternate" href="http://example.com/nl/" hreflang="nl">
<link rel="alternate" href="http://example.com/en/" hreflang="x-default">
</head>
<body>
<p>Dit is een Nederlandstalige web pagina.
Deze pagina is beschikbaar in het Engels.
De standaardtaal van deze pagina is Engels.
</body>
</html>