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 to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources