HTML lang
Created By: chatGPT
In HTML, the lang attribute is used to specify the language of the content within an HTML element. This is important for accessibility and search engines. Setting the language helps screen readers and other assistive technologies to interpret the content correctly.
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Language Attribute Example</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This page is written in **English**.</p>
</body>
</html>
The lang attribute can also be applied to any other HTML elements to specify the language used for that specific part of the document. For instance, if you have a section in French, you can set its language accordingly.
<p lang="fr">Bonjour le monde!</p>
<p lang="es">¡Hola Mundo!</p>
It's common to use the ISO 639-1 language codes. Some examples include: 'en' for English, 'fr' for French, and 'es' for Spanish. When setting the lang attribute, it is good practice to choose the most specific code that applies to your content.
<html lang="fr">
<body>
<h1>Bienvenue sur notre site</h1>
</body>
</html>