Jump to content

Recommended Posts

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 by LittleJoe
Link to post
Share on other sites

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...