Different languages ​​in the title and content of the ABBR HTML tag

Suppose I am writing an article in HTML. The language of the article is Swedish, so I <html lang="sv"> . Now I want to mark the abbreviation correctly in the following text:

 HTML kan användas till mycket. 

To this end, I first do

 <abbr title="HyperText Markup Language">HTML</abbr> kan användas till mycket. 

This alone is not enough, because the language of the title attribute is Swedish ( sv ). In addition to the theoretical problem, this will make screen readers pronounce the title very uncomfortable. To fix this, I could do

 <abbr title="HyperText Markup Language" lang="en">HTML</abbr> kan användas till mycket. 

This is even worse, however, since now the abbreviation 'HTML' will be read in Enligsh instead of Swedish [so from a Swedish point of view it will sound like “ejtsch-ti-emm-ell” instead of “HA-te-um-outhouse”].

Therefore, the abbreviation or text content of abbr node must be in Swedish, but the title attribute must be in English. What is the preferred (HTML5) way of labeling this? it

 <abbr title="HyperText Markup Language" lang="en"> <span lang="sv">HTML</span> </abbr> kan användas till mycket. 

?

+6
source share
1 answer

Your conclusion is correct: when marking up a language in HTML, you cannot specify the contents of an element as in a language other than its attribute values, since the lang attribute sets both of them. And the workaround is the one you found: use the internal markup for the content. There is no difference between HTML 4 and HTML5.

However, this is a very theoretical problem.

Firstly, abbr markup is practically useless in practice. Abbreviations should be explained, when necessary, in plain text content, not in attributes. Speech browsers can optionally read the values ​​of the title attributes, but in normal mode they ignore them - people who use speech browsers prefer fast reading and are often used to fairly high speech speeds, and the wording of the abbreviations will violate this.

Secondly, “abbreviations,” such as “HTML” (which is really the correct name, not anything else), rarely need to be spelled out in speech. You would not want to hear a speech like "The new version of the HyperText markup language is HyperText five markup language, which has many extensions for the hypertext markup language four."

Thirdly, language markup is mainly intended for writing. In most situations, this is simply ignored. Google doesn't care. Browsers can use it to determine the default font to be used, but most pages set their own fonts, so the default values ​​do not matter. Some speech browsers can recognize several languages ​​from the lang attributes, but most of them are not: they read content according to the rules for the language selected by the user. Those who use language markup can make a distinction between English and American English, so if you still think that language markup matters, consider using lang="en-GB" in this context. (I assume that most people who speak Swedish will find the resulting pronunciation more understandable and natural than Standard American, but I could be wrong.)

+2
source

Source: https://habr.com/ru/post/950619/


All Articles