I am coding a multilingual site and I have following navigation:
<nav id="language">
<ul>
<li><a href="/en/" hreflang="en">en</a></li>
<li><a href="/de/" hreflang="de">de</a></li>
<li>fr</li>
</ul>
</nav>
Can I improve semantics? With Microdata or tags attributes e.g
abbr
elementsYou should add abbr
, giving the full language name in the corresponding language:
<nav id="language">
<ul>
<li><a href="/en/" hreflang="en"><abbr lang="en" title="English">en</abbr></a></li>
<li><a href="/de/" hreflang="de"><abbr lang="de" title="Deutsch">de</abbr></a></li>
<li><abbr lang="fr" title="Français">fr</abbr></li>
</ul>
</nav>
title
attribute for a
You could add a title
attribute to a
with a content like: "Switch to the English translation of this page"
nav
You could give this nav
section a heading like "Translations of this page" (for the English page).
If you don't want it to be visible on the page, hide it visually so that it is still read to screenreader users (e.g. with the clip
method).
(If you provide such a heading, you probably don't need the title
attribute on a
anymore.)
link
element (in head
)For bots, you could link the translations with link
elements in the head
of your pages:
<link rel="alternate" href="/de/" hreflang="de" />
<link rel="alternate" href="/en/" hreflang="en" />
I think perhaps changing en
to Change site language to English
would improve semantics. As it stands en
is pretty cryptic without the context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With