For linking to different language versions of the current page, I made these hyperlinks:
<a href="/nl/pageid" lang="nl-nl" hreflang="nl-nl">Nederlands</a>
<a href="/en/pageid" lang="en-gb" hreflang="en-gb">English</a>
lang=
and hreflang=
be used?en
over en-gb
in such hyperlinks?en-gb
over en
in such hyperlinks?Can I use both lang AND hreflang in one hyperlink to define the target page language?
You can use them both, and you are using them correctly in your example, but you can't use them both to define the target page language.
In your code:
<a href="/nl/pageid" lang="nl-nl" hreflang="nl-nl">Nederlands</a>
lang="nl-nl"
means that the contents of the element (i.e. the word Nederlands) are written in Dutch.
hreflang="nl-nl"
means that the primary language of the document at the URL /nl/pageid
is written in Dutch.
Note that the lang
is inherited, so you only need it when switching languages. You should define the primary language in the root element (for example <html lang="en-gb">
).
What are the benefits of en over en-gb in such hyperlinks? What are the benefits of en-gb over en in such hyperlinks?
In theory, more specific information about what version of a language is being used is better (especially when dealing with, for example, text to speech tools which can switch how they pronounce words).
It's always possible that some tool which handles American English is going to have an algorithm that nope-outs at the sight of British English instead of just treating it as English, but I've absolutely no data to support that.