View video tutorial

HTML translate Attribute

HTML

The HTML translate attribute specifies whether the content of an element should be translated when the page is localized.

Definition and Usage


➔ The translation attribute is a global attribute and can be applied to any HTML element.

➔ It accepts two possible values: yes (default) and no.

Syntax
//In HTML
<div translate="no" id="sample">
    <p>This div will not be translated into local language.</p>
</div>

//In Javascript
let element = document.querySelector("#sample");
//element.translate= "no";
//element.setAttribute('translate', 'yes');

Applies to

This attribute can be used on the following element.

Attribute Element
translate Global Attributes

Example

<!DOCTYPE html>
<html>
<head>
    <title>HTML translate attribute Example</title>
</head>
<body>
    <h3>HTML translate attribute Example</h3>
    <p>The translate attribute translates the content of an element into the local language.</p>
    <div translate="no" id="sample">
        <p>This div will not be translated into local language.</p>
    </div>
</body>
<script>
    //let element = document.querySelector("#sample");
    //element.translate= "no";
    //element.setAttribute('translate', 'yes');
</script>
</html>
Try it Now »

Click on the "Try it Now" button to see how it works.