Serving Webpages in Multiple Languages: A Guide

KirstyKirsty
1 min read

This guide explores how to create webpages that display content in multiple languages.

Many developers rely on the default HTML boilerplate generated by the Emmet shortcut (! + Tab) in VS Code. This boilerplate often includes the lang="en" attribute, which informs the browser of the webpage's primary language. This attribute is what triggers Chrome's automatic translation pop-up if it's missing.

To offer your webpage in multiple languages, you'll need to assign the appropriate language code within the lang attribute to any text that deviates from your default document language. For example, if your content includes Spanish text, you'd use the following code to indicate the language switch:

<p lang="es">Hola, yo soy Kirsten.</p>

By including the lang attribute with the correct language code, you ensure your text remains accessible to a global audience. Even if users aren't familiar with the language you're using, their browser might offer a translation into their preferred language.

I hope this explanation is helpful!

12
Subscribe to my newsletter

Read articles from Kirsty directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Kirsty
Kirsty

Hi, I’m Kirsten, a passionate web developer. I’m using JavaScript, React, and more to build impactful projects. After 2 years of learning through trial and error, I’m ready to share my journey and create work that solves problems. 📬 Connect with me: Twitter: twitter.com/km_fsdev Blog: kirsty.hashnode.dev GitHub: github.com/ofthewildire