dir
On this page
HTML dir Attribute (HTML目录属性)
The HTML dir attribute specifies the text direction of an element’s content. It is important for enabling HTML in right-to-left scripts (e.g. Arabic, Hebrew, etc.). Numerous languages are written with these scripts. (HTML dir属性指定元素内容的文本方向。在从右到左的脚本(例如阿拉伯语、希伯来语等)中启用HTML非常重要。许多语言都是用这些脚本编写的。)
You can use this attribute on any HTML element. It is a part of the Global Attributes. (您可以在任何HTML元素上使用此属性。它是全局属性的一部分。)
The dir attribute can have the following values: (Dir属性可以具有以下值:)
ltr: displays the text in left-to-right text direction. It is the default value. (- ltr :以从左到右的文本方向显示文本。这是默认值。)
rtl: displays the text in right-to-left text direction. (- rtl :以从右到左的文本方向显示文本。)
auto: lets the browser determine the text direction, based on the content. (-自动:让浏览器根据内容确定文本方向。)
Syntax
Syntax (语法)
<tag dir="ltr|rtl|auto"></tag>
Example of the HTML dir attribute:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p dir="rtl">Example of the HTML "dir" attribute:</p>
</body>
</html>