Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
amilli0nyawn
1,079 PointsIf the webpage is written in more than one languages is it still useful to add language attributes?
(Or perhaps i've misunderstood the usage of language attributes, does it specifies the language on its web page or the language used for coding?)
2 Answers
Michael Hulet
47,913 PointsThe lang attribute specifies the spoken language that the element (or in the case of this video where lang is specified on the html tag, the page) is in. For example, this page is in English on my machine, so the html tag might look like this:
<html lang="en">
<!-- Page code here -->
</html>
Let's say this page was also in Swedish. The Swedish version of this page's html tag might look like this:
<html lang="sv">
<!-- Page code here -->
</html>
HTML uses the ISO 639-1 standard to specify language codes, and here's a full list of all possible codes
amilli0nyawn
1,079 PointsThank you, thats very helpful.
amilli0nyawn
1,079 Pointsamilli0nyawn
1,079 PointsThanks Hulet, but say if I have both Swedish and English on the same website. I only have to declare the primary language right?
Michael Hulet
47,913 PointsMichael Hulet
47,913 PointsEvery tag supports the
langattribute, so you could declare the default language on thehtmltag and declare that specific tags on a page are in Swedish, like this: