Clearing Source Code Clutter

Apr 1
15:14

2013

Sadhiv Mahandru

Sadhiv Mahandru

  • Share this article on Facebook
  • Share this article on Twitter
  • Share this article on Linkedin

When humans communicate, they use language, like right now I'm writing this article in English. I could write in the Norwegian. Things are no different when it comes to the Web. When we publish content to the web and people read it, they quickly recognise the language it was written in.

mediaimage

But computers aren't always that smart. To help them,Clearing Source Code Clutter  Articles we can add a piece of code in the header of our pages that tells the browsers and search engines what language the content is written in. This has some surprising benefits. 

What we want to do is tell the browser and the search engines what language the content is written in.

Now when I say language, I mean the language the content is written in, not the code language. The accessibility benefit of this is twofold. First of all browsers can detect the language and offer to translate the content on that page. You may have noticed that Google Chrome, in particular, wants to translate content you visit in another language.

Now, Google Chrome is actually tracking the language on the page itself and making a guess, but other browsers and future browsers will be tracking the language code that's embedded into your content. In addition, text-to-speech browsers can read back the text in the correct language. So if you wrote something in English it'll read it back in English. If you wrote it in German or in Norwegian, it'll read it back in German or Norwegian. This is really important because you can actually embed multiple language codes in one page. So, for instance, if you had a page that was mostly written in English but had a quote in French, you could define that quote as French text, and the Text-to-Speech browser would then notice that and switch over the languages. 

The SEO company in Manchester benefit is quite interesting. Search engines index pages based on the language the content is written in. That means when you make a search on Google for instance, you can say, I only want to see results written in a specific language. By default, it will default to the language you search in, but you can go and search for a different language. 

That also means if you define the wrong language for your page or you don't define a language for your page, your page may not appear in searches that are targeting a specific language. So how do we declare a language for a page? It's really simple. At the very top of your page you have an HTML tag. What you want to do is add to the html tag the variable lang= and then whatever language code you want to use. 

The world is populated with people who speak many different languages and when we use the language tag, we need to target those specific languages. There is an ISO language code that targets different languages, and if you want to find a specific language, you can go to the w3schools.com site and find the HTML language code reference, where you have a complete list of all the standard languages. 

You will see it goes all the way from A to Z. Now it's worth noting that in addition to the standard languages, you also have variables. For instance, you will notice, it says en-US, because this is US English. You can also say en-CA, for Canadian English, and so on. 

Adding a language tag to your page is easy and has a huge advantage, both for accessibility and for SEO. In addition, you add current and future features to the sites by providing language info, so applications can identify and use this info on the site.

Categories: