LittleJoe Posted July 3, 2013 Share Posted July 3, 2013 (edited) I'm wondering whether the lang attribute applies to the rendered content only or whether it also applies to metadata, comments and code (variable names, CSS id/class names). If my metadata etc is in US English but the rendered content is in French, which is the right way to go? 1) Language declared in the root element and then changed in the body element where the user content is. <!DOCTYPE html><html lang="en-US"> <head> <meta charset="UTF-8"/> <title>Title</title> </head> <body lang="fr"> </body></html> 2) Language for metadata etc declared in the head since that's where the metadata is and then changed in the body element where the user data goes. <!DOCTYPE html><html> <head lang="en-US"> <meta charset="UTF-8"/> <title>Title</title> </head> <body lang="fr"> </body></html> 3) Language declared as French in the root element and metadata language not declared (because it doesn't apply to it). <!DOCTYPE html><html lang="fr"> <head> <meta charset="UTF-8"/> <title>Title</title> </head> <body> </body></html> Edited July 3, 2013 by LittleJoe Link to comment Share on other sites More sharing options...
Ingolme Posted July 3, 2013 Share Posted July 3, 2013 The lang attribute describes the language that the readable content is in. Variable names and other things aren't considered a "language" so don't worry about that. If what the viewer sees is only French, then setting it on the <html> element is good. If you have a paragraph in English then you can open it with <p lang="en"> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now