目录搜索
Attributesaccesskey (attribute)class (attribute)contenteditable (attribute)contextmenu (attribute)data-* (attribute)dir (attribute)draggable (attribute)dropzone (attribute)Global attributeshidden (attribute)id (attribute)itemid (attribute)itemprop (attribute)itemref (attribute)itemscope (attribute)itemtype (attribute)lang (attribute)slot (attribute)spellcheck (attribute)style (attribute)tabindex (attribute)title (attribute)translate (attribute)Elementsaabbraddressareaarticleasideaudiobbasebdibdoblockquotebodybrbuttoncanvascaptioncitecodecolcolgroupdatadatalistdddeldetailsdfndialogdivdldtemembedfieldsetfigcaptionfigurefooterformh1headheaderhrhtmliiframeimginputinput type="button"input type="checkbox"input type="color"input type="date"input type="datetime"-localinput type="email"input type="file"input type="hidden"input type="image"input type="month"input type="number"input type="password"input type="radio"input type="range"input type="reset"input type="search"input type="submit"input type="tel"input type="text"input type="time"input type="url"input type="week"inskbdlabellegendlilinkmainmapmarkmenumenuitemmetameternavnoscriptobjectoloptgroupoptionoutputpparampicturepreprogressqrprtrtcrubyssampscriptsectionselectslotsmallsourcespanstrongstylesubsummarysuptabletbodytdtemplatetextareatfootththeadtimetitletrtrackuulvarvideowbrMiscellaneousAttributesBlock-level elementsCORS enabled imageCORS settings attributesElementInline elementsKinds of HTML contentLink typesMicrodataOptimizing your pages for speculative parsingPreloading contentReferenceSupported media formatsUsing the application cacheObsoleteacronymappletbasefontbigblinkcentercommandcontentdirelementfontframeframesethgroupimageinput type="datetime"isindexkeygenlistingmarqueenextidnoframesplaintextstrikettxmp
文字

全局属性dir是一个指示元素中文本方向的枚举属性。它的取值如下:

  • ltr, 指从,用于那种从左向右书写的语言(比如英语);

  • rtl, 指从,用于那种从右向左书写的语言(比如阿拉伯语);

  • auto, 指由用户代理决定方向。它在解析元素中字符时会运用一个基本算法,直到发现一个具有强方向性的字符,然后将这一方向应用于整个元素。

使用说明

这个属性对有不同语义的<bdo>元素是必须的。

  • 这个属性在<bdi>元素中不可继承。未赋值时,它的默认值是auto。

  • 这个属性可以被CSS属性directionunicode-bidi覆盖,如果CSS网页有效且该元素支持这些属性的话。

  • 由于文本的方向是和内容的语义而不是和表现相关,因此有可能的话,网页开发者使用这一属性而非CSS属性是被推荐的。这样,即使在不支持CSS或禁用CSS的浏览器中,文本也会正常显示。

  • auto应当用于方向未知的数据,如用户输入的数据,最终保存在数据库中的数据。

规范

规范

状态

评论

WHATWG HTML生活标准该规范中'dir'的定义。

生活水平

最新的快照HTML5.1没有变化

HTML5.1该规范中'dir'的定义。

建议

WHATWG HTML Living Standard的快照,HTML5没有改变

HTML5该规范中'dir'的定义。

建议

WHATWG HTML Living Standard的快照,从HTML 4.01规范中增加了自动值,现在是一个真正的全局属性。

HTML 4.01规范该规范中'dir'的定义。

建议

除<applet>,<base>,<basefont>,<bdo>,<br>,<frame>,<frameset>,<iframe>,<param>和<script>外的所有元素均受支持。

浏览器兼容性

Feature

Chrome

Firefox (Gecko)

Internet Explorer

Opera

Safari

Basic support

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

Feature

Android

Chrome for Android

Firefox Mobile (Gecko)

IE Mobile

Opera Mobile

Safari Mobile

Basic support

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

上一篇:下一篇: