Search code examples
htmltextareasemanticslang

What does the html lang attribute mean on textareas or other user editable elements?


I'm developing a multi language enabled CMS for a project of mine, and I have a tabbed interface with one tab for each language; these tabs are used to enter the various translations of a single content (article, post, or other kinds of elements).

So I thought that it would be correct to explicitly set the respective lang attribute value for each ,,etc in each tab, and so did I.

Then it came to me that while the meaning of the lang attribute is very clear when applied to fixed elements of the page (it clearly means "browser, this text is in x language"), it is much more dubious if put in a textarea: does it mean that the user SHOULD use that language while writing in the textarea?

Or is simply inviting the user to write in that language, but any language would be accepted?

Or what?

As a programmer writing a translation interface, my hope surely is that people WOULD NOT enter French text in a control tagged for English text, as this would simply make my system go crazy, but I was wondering if someone has found a clear and standard answer to that question, since my research on the web didn't find anything definitive.

Thanks in advance for your insight!

To make my question clearer: while the semantical meaning of the lang attribute is perfectly clear when applied to content provided by the web site ("this content is expressed in that language"), it isn't so clear when applied to user editable fields, which may also be initially empty:

It means "only text in this language will be accepted here"? Or "the web site kindly asks you to write in this language here"? Or "the web site would only help by giving writing tools in this language"?

In other words, I do know how web browsers react to this attribute in user editable fields, but what is the semantical meaning of this attribute in this case?


Solution

  • It's not a normative source, but since when I asked the question I've found this MDN page: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang

    That states:

    "The lang global attribute helps define the language of an element: the language that non-editable elements are written in, or the language that the editable elements should be written in by the user."

    This is much clearer that previous text I had found on the subject, and I though it would be interesting putting it here.