HTML - translate 属性



HTML 的 **translate** 属性用于指定在页面本地化时是否应翻译元素的内容。

此属性对于确保网页信息易于理解并适应多种语言和文化环境至关重要。

语法

<element translate = "no/yes" >

应用于

由于 translate 是 HTML 中的全局属性,因此 HTML 中的所有标签都支持 translate 属性。

HTML translate 属性示例

以下示例将说明 HTML height 属性,以及我们应该在哪里以及如何使用此属性!

使用 translate 属性阻止自动翻译

在以下示例中,我们正在创建 HTML 文档并使用 translate 属性来要求翻译工具不要翻译页脚部分中的公司品牌名称。

<!DOCTYPE html>
<html>

<body>
   <footer>
      <small> © 2020 
         <span translate="no">
            tutorialspoint
         </span>
      </small>
   </footer>
</body>

</html>

允许翻译段落元素

在此示例中,我们将 translate 属性值设置为 yes。以便段落可以由外部来源翻译。

<!DOCTYPE html>
<html>

<body>
   <h1>tutorialspoint</h1>
   <h2>translate attribute</h2>
   <p translate="yes">
      This can be translated
   </p>
</body>

</html>

支持的浏览器

属性 Chrome Edge Firefox Safari Opera
translate 不支持 不支持 不支持 不支持 不支持
html_attributes_reference.htm
广告

© . All rights reserved.