HTML translate Attribute

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
i18n & Localization

Introduction

The translate attribute is a global HTML feature that controls whether the content inside an element should be automatically translated by browsers and translation tools (such as Chrome’s built-in page translate).

It is especially useful on multilingual sites when you need to protect brand names, product codes, technical terms, or sample text from being incorrectly translated.

What You’ll Learn

01

yes / no

Two values.

02

Global

Any element.

03

Brand names

Keep as-is.

04

With lang

Language hint.

05

JavaScript

boolean prop.

06

Browser translate

Chrome, etc.

Purpose of translate

The primary purpose of the translate attribute is to indicate whether an element’s text is eligible for machine translation. By default, translation is enabled (yes), but you can opt out with translate="no" for fine-grained control.

This helps multilingual audiences: most of the page can be translated while critical strings (logos as text, API endpoints, code samples) stay unchanged.

💡
Not a replacement for proper localization

translate hints to automatic tools. For professional multilingual sites, still provide human translations and use the lang attribute correctly.

📝 Syntax

Add translate to any element with yes or no:

translate.html
<p translate="no">CodeToFun</p>
<p>This paragraph translates by default.</p>

Syntax Rules

  • Global attribute — valid on any HTML element.
  • Values: yes (default) or no.
  • Omitting the attribute means translation is allowed.
  • Child elements inherit unless they set their own translate value.
  • IDL property: HTMLElement.translate (boolean: true = yes, false = no).
  • Pair with lang on <html> or elements for language context.

💎 Values

The translate attribute accepts two main values:

  • yes — Default. Content may be translated by browsers and translation services.
  • no — Content should not be translated (brand names, code, proper nouns).
translate-values.html
<p translate="no">This paragraph will not be translated.</p>

<p>This paragraph will be translated by default.</p>

⚡ Quick Reference

ValueMeaningUse case
yes (default)Allow translationBody copy, instructions
noBlock translationBrands, code, URLs
JavaScriptel.translate = falseDynamic toggle
With langLanguage of textMultilingual pages
ScopeGlobal attributeAny element
ConsumersBrowser translate, MT toolsNot all tools honor it

Applicable Elements

ElementSupported?Typical use
<p>, <span>YesParagraphs and inline text
<h1><h6>YesHeadings (rarely need no)
<code>, <pre>YesProtect code from translation
<a>YesLink text or URLs
Any HTML elementYesGlobal attribute

translate vs lang vs manual i18n

ApproachWhat it doesBest for
translate="no"Skip auto-translationNames, code snippets
lang="fr"Declares languageScreen readers, hyphenation
Separate translated pagesHuman-quality copyProduction multilingual sites
Browser “Translate page”Machine translationUser-initiated, respects translate

Examples Gallery

Block translation on one paragraph, protect a brand name, and toggle translate with JavaScript.

👀 Live Preview

Markup showing mixed translation behavior (browser translate would skip the first line):

API endpoint: /api/v1/users

Welcome to our documentation. Read the guide below.

Example — translate yes and no

Two paragraphs with different translation settings:

translate.html
<p translate="no">This paragraph will not be translated.</p>

<p>This paragraph will be translated by default.</p>
Try It Yourself

How It Works

The first paragraph has translate="no", so browser translate features should leave it unchanged. The second paragraph uses the default (yes).

Example — protect brand and code

Common real-world pattern on a multilingual page:

brand.html
<p>
  Welcome to <span translate="no">CodeToFun</span> tutorials.
</p>

<code translate="no">console.log("Hello");</code>

How It Works

Only the wrapped brand name and code sample opt out of translation; surrounding sentence text can still be translated.

Dynamic Values with JavaScript

Toggle translation eligibility at runtime:

dynamic-translate.html
<p id="dynamicElement">This text starts with translation blocked.</p>

<script>
  document.getElementById("dynamicElement").translate = false;
  // Later: element.translate = true to allow translation
</script>

How It Works

The DOM property translate is a boolean. Set false for no and true for yes. The try-it example includes a button to toggle translation on and off.

♿ Accessibility

  • Use lang for language — Screen readers use lang, not translate, to pick pronunciation.
  • Do not hide translations from users who need them — Only block auto-translation where it would break meaning (names, code).
  • Provide real localized contenttranslate="no" is not a substitute for accessible multilingual UX.
  • Test with browser translate — Verify protected strings stay intact in Chrome and other browsers.
  • Keep critical UI in the page language — Use proper i18n for buttons and labels users rely on.

🧠 How translate Works

1

Author sets value

yes or no.

HTML
2

User translates page

Browser feature.

Action
3

Tool skips no

Protected text.

Filter
=

Smarter i18n

Better UX.

Browser Support

The translate attribute is supported in all modern browsers. Chrome, Edge, Firefox, and Safari honor it for built-in translation features.

Universal · Fully supported

Modern browser support

Major browsers respect translate when offering page translation.

100% Modern browsers
Google Chrome Supported
Supported
Mozilla Firefox Supported
Supported
Apple Safari Supported
Supported
Microsoft Edge Supported
Supported
translate attribute Excellent

Bottom line: Safe to use; test with third-party translation plugins because not every tool honors the attribute.

💡 Best Practices

✅ Do

  • Use translate="no" on brand names and code
  • Set lang on the document and foreign-language sections
  • Apply translate only where auto-translation causes problems
  • Test with browser “Translate page” features
  • Use boolean element.translate in JavaScript

❌ Don’t

  • Mark entire pages translate="no" without good reason
  • Assume all translation services respect the attribute
  • Replace professional localization with translate hints alone
  • Confuse translate with lang
  • Block translation on user-facing instructions users need in their language

Conclusion

The translate attribute is a valuable tool for controlling automatic translation of specific elements in HTML. With yes and no, you can protect sensitive strings while letting the rest of the page translate freely.

Combine it with proper lang attributes and human translations for the best multilingual experience.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about translate

Bookmark these when building multilingual pages.

5
Core concepts
yes/no 02

Two values

Default yes

Syntax
🏷️ 03

Brand/code

use no

Pattern
⚙️ 04

boolean JS

true/false

Dynamic
🗣 05

Plus lang

Not replace

i18n

❓ Frequently Asked Questions

It tells browsers and translation tools whether to translate an element’s text.
yes (default) allows translation; no blocks it.
Not directly. It improves UX for machine translation. SEO for multiple languages relies on proper lang, hreflang, and localized content.
Use the boolean property: element.translate = false (no) or true (yes).
For brand names, product codes, URLs, and code samples that must not be altered by auto-translation.
No. lang declares language; translate controls whether automatic translation should run.

Practice translation control

Try the yes/no paragraphs and toggle translate with the button example.

Try dynamic toggle →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful