Skip to content

The translate Attribute

Global Attribute

The translate attribute specifies whether an element’s text content and attribute values should be translated when the page is localized or when using browser translation tools. It’s essential for protecting brand names, technical terms, code examples, and other content that shouldn’t be translated.

<element translate="value">Content</element>
ValueDescription
yes (default)Content should be translated
noContent should NOT be translated
Result
Result
Result
Result

Brand names and trademarks: TechPro™, Nike®, Coca-Cola® ✓ Product names: iPhone 15, PlayStation 5 ✓ Person names: María García, João Silva ✓ Place names: São Paulo, München, København ✓ Code examples: variables, functions, syntax ✓ Technical terms: HTML, CSS, JavaScript ✓ Domain names: example.com, github.io ✓ Email addresses: [email protected]Phone numbers: +1 (555) 123-4567 ✓ Prices and currencies: $99.99, €49,99 ✓ Measurement units: 5kg, 10mph ✓ Serial numbers: ABC-123-DEF

<!-- Brand names -->
<h1><span translate="no">Nike</span> Running Shoes</h1>
<!-- Code examples -->
<code translate="no">console.log('Hello')</code>
<!-- Person names -->
<p>Author: <span translate="no">José García</span></p>
<!-- Places -->
<address translate="no">
123 Main Street<br>
São Paulo, SP 01234<br>
Brazil
</address>

Allow Translation (translate=“yes” or omit) For:

Section titled “Allow Translation (translate=“yes” or omit) For:”

Regular descriptive textInstructions and help textUI labels and buttonsError messagesMarketing copyBlog posts and articles

<!-- These should be translated -->
<p>Click the button below to continue.</p>
<button>Submit Form</button>
<p class="error">Please enter a valid email address.</p>
<!-- Specify language for non-translated content -->
<blockquote translate="no" lang="fr">
Bonjour, comment allez-vous?
</blockquote>
<span translate="no" lang="ja">こんにちは</span>
<!-- Good: Specific to brand name -->
<p>Buy <span translate="no">Nike Air Max</span> shoes today!</p>
<!-- Less ideal: Entire paragraph non-translatable -->
<p translate="no">Buy Nike Air Max shoes today!</p>
<article>
<h2>Using the <code translate="no">fetch()</code> API</h2>
<pre translate="no">
fetch('https://api.example.com/data')
.then(response => response.json())
.then(data => console.log(data));
</pre>
<p>
The <code translate="no">fetch()</code> function returns a Promise
that resolves to the Response object.
</p>
</article>
<!-- Brand name in title attribute -->
<img
src="logo.png"
alt="Logo"
title="TechPro Inc."
translate="no">
<!-- URLs shouldn't be translated -->
<a href="https://example.com" translate="no">
Visit our website
</a>

Modern browsers offer built-in translation:

  • Chrome: Right-click → Translate to [Language]
  • Edge: Right-click → Translate to [Language]
  • Firefox: Uses extensions like Google Translate
  • Safari: Translation via extensions

The translate attribute helps these tools:

  • Skip content marked translate="no"
  • Maintain proper names and technical terms
  • Preserve code examples and identifiers

The translate attribute is inherited by descendants:

<!-- All children inherit translate="no" -->
<div translate="no">
<h1>TechPro X1</h1>
<p>$299.99</p>
<code>product_id: 12345</code>
</div>
<!-- Override parent's translate -->
<div translate="no">
<h1>TechPro X1</h1>
<p translate="yes">This description can be translated.</p>
<p>But the price: $299.99 cannot be.</p>
</div>
const element = document.getElementById('myElement');
// Set translate
element.translate = false;
element.setAttribute('translate', 'no');
// Get current value
console.log(element.translate); // false
// Check if element should be translated
if (element.translate) {
console.log('Element can be translated');
} else {
console.log('Element should not be translated');
}

The translate attribute:

  • Does not affect screen reader behavior
  • Is only a hint for translation tools
  • Should still be combined with proper semantic HTML
<button translate="no" aria-label="Play">
</button>

Always use lang attribute with translate="no":

<!-- Helps screen readers pronounce correctly -->
<span translate="no" lang="es">Hola</span>
<span translate="no" lang="fr">Bonjour</span>
<span translate="no" lang="de">Guten Tag</span>
  1. Chrome: Right-click page → “Translate to [language]”
  2. Edge: Similar to Chrome
  3. Online tools: Google Translate, DeepL, etc.
  4. Check: Verify translate=“no” content remains unchanged
// Check if translate attribute is set correctly
const brandNames = document.querySelectorAll('.brand-name');
brandNames.forEach(element => {
if (element.translate !== false) {
console.warn('Brand name missing translate="no":', element);
}
});

Universal support across modern browsers:

BrowserSupportNotes
Chrome19+Full support
Firefox66+Full support
SafariNoDoesn’t support translate attribute
Edge79+Full support
  • lang - Specifies the language of content
  • dir - Text direction (LTR/RTL)