Lang-attribute

syntax summary

So, to continue on our attributes lesson, we need a way to convey to the browser what language we prefer our website to be understood in.

This has the benefit of letting the browser and search engines know what language your website is in so that it can offer the best solutions to the person performing the search.

For example, take the website, Procatinator...it's based out in Spain, the website denotes that Spanish is the language of choice. This thus provides this result when I come to the website...

Cat videos and snazzy music...hello entertainment, goodbye productivity!!!

The language attribute is just another way attributes add descriptive qualities to your website.

how we do...

To utilize the language attribute, you simply place it in the opening tag of the element you want to use it in.

The first step though is to know what language code you need for your desired language. Lucky for you, I happen to have a list of language codes on hand.

So now that we have the language code, let's get to work...your language attribute should look something like this...

<html lang="en-us">

Again, an attribute consists of the attribute name, an equal sign, and the attribute value encased in double-quotation marks.

Okay, so one last thing, where to put your language attribute? The answer is simple but complex. The primary place to place your language attribute is always going to be the opening html tag of the html-element. That covers the whole HTML document.

Now, because of SEO, there will be times where you might need to cite or source content that comes in a different language. Like, you're writing about a trip to Mexico and you need to inject this line of code...

<p lang="es">Donde es biblioteca?</p>

That line of code will specifically denote that there is Spanish in your code, and help with your SEO in some fashion. 

Encycodepedia is a reference guide to the common syntax and terminology used in everyday programming.

Encycodepedia HTML covers the structural component of building websites.