Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The translate property of the HTMLElement interface indicates whether an element's attribute values and the values of its Text node children are to be translated when the page is localized, or whether to leave them unchanged.
It reflects the value of the translate HTML global attribute.
A boolean value that is true if an element's attribute values and the values of its Text node children are to be translated when the page is localized, false otherwise.
The following example shows how to enable or disable translation via script:
<div>
<span>The content may always be translated: </span>
<span translate="yes">El contenido será traducido</span>
</div>
<div>
<span id="translate-label">The content may be translated:</span>
<span id="translate-element" translate="no">
El contenido puede ser traducido.
</span>
</div>
<input id="translate-controller" type="checkbox" /> Enable translation
const label = document.getElementById("translate-label");
const element = document.getElementById("translate-element");
const controller = document.getElementById("translate-controller");
controller.addEventListener("change", (e) => {
if (controller.checked) {
element.translate = true;
label.innerText = "The content may be translated:";
} else {
element.translate = false;
label.innerText = "The content may not be translated:";
}
});
| Specification |
|---|
| HTML> # dom-translate> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
translate |
19 | 79 | 111 | 15 | 6 | 25 | 111 | 14 | 6 | 1.5 | 4.4 | 6 |
translate HTML global attribute
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/translate