user1815131
user1815131

Reputation: 101

HTML tags for translation

What HTML markup and tags should I use if write in article.

This `foreign word` translated from foreign language as `this word in native reader language word`.

Upvotes: 1

Views: 2028

Answers (3)

Karol S
Karol S

Reputation: 9402

Nowadays, you can mark content you don't want online services to translate with the translate="no" attribute:

This <span translate="no">`foreign word`</span>
translated from foreign language
as `this word in native reader language word`.

The value has to be either blank (which is the default and means "yes"), "yes", or "no".

The exact behaviour may differ between different translation service providers, but the simple case of using translate="no" to disable translation of text in the tag content should work reliably everywhere.

Upvotes: 0

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201588

There is no HTML markup specifically for such purposes. It really depends on the conventions of the human language used on the page, as well as presentation style. Typically, either quotation marks or italic is used when mentioning words or expressions, rather than using them in normal use. For these, there are different options in HTML. Quotation marks are best written as such, using proper characters as per language rules, though some people still think that q markup is useful. For italic, you can use i markup or CSS font-style: italic.

In any case, if it is relevant to your purposes somehow that translations are marked up, e.g. in order to style them uniformly later, the best shot is to use classes.

The use of lang markup is recommendable in principle, and it is gaining some practical importance (e.g., for automatic hyphenation). In the following example, the span markup is used only to indicate the language (because you need an element for that):

The French word “<span lang=fr>cheval</span>” means “horse”.

Upvotes: 1

Quentin
Quentin

Reputation: 943560

Use the most appropriate markup (using a generic element if nothing better presents itself) with a lang attribute.

<body lang="en">
<!-- etc -->
<p><span lang="de">unbekanntes Flugobjekt</span> is German for UFO.</p>

This won't generally provide automatic translation, but the option exists for browsers / browser extensions to provide such a mechanism. Translation tools such as Google Translate may use it as a hint to identify the "from" language. Text to speech software may use it to select a pronunciation guide. And so on.

Upvotes: 3

Related Questions