What is the translate attribute in HTML?

Overview

In HTML, the translate attribute is used to identify whether the text content of an element can be translated to another language or not after web page localization.

Syntax

<div translate="yes">Hello</div>

Parameters

The translate attribute takes two values:

  • yes: This tells that the content of the element can be translated.

  • no: This tells that the content of the element should not be translated.

Example

<html>
<head>
</head>
<body>
<footer>
<small>&#169; 2022 <span translate="no">Educative.io</span></small>
</footer>
</body>
</html>

Explanation

Lines 5-7: We create a footer section and add a span element that contains the name of the brand inside it. Because there is no need to translate the name of the brand or product while localizing a website, we add the translate="no" tag to the span element. This makes sure that the content of the span element is not translated when the web page is translated to other languages using the translation tool.

Note: The translate attribute is newly added in HTML5.

New on Educative
Learn any Language for FREE all September 🎉
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
🎁 G i v e a w a y
30 Days of Code
Complete Educative’s daily coding challenge every day in September, and win exciting Prizes.

Free Resources