問題描述
我已閱讀 W3C 的頁面,但對我來說仍然很模糊.role
屬性的目的是為了闡明代碼嗎?還是會被某些瀏覽器或蜘蛛解釋?
I have read W3C's page on this, but it is still vague to me. Is the role
attribute's purpose to clarify the code? Or will it be interpreted by some browsers or spiders?
是否可以使用某些 JavaScript 庫將其用作 DOM 選擇器(我認為由于 id
屬性必須是唯一的,這可以用于識別頁面上的多個資源)?
Can it be used as a DOM selector using some JavaScript libraries (I am thinking so since the id
attribute has to be unique, this could be used to identify multiple resources on a page)?
推薦答案
簡短版:
角色屬性可能會為未來的瀏覽器提供一種以獨立于設備的方式智能處理某些 XML 元素的方法.例如,在桌面和手持環境中的瀏覽器上都可以對標有導航"角色屬性的無序列表進行智能解釋,使其在兩種環境中都能清晰顯示.
The Role Attribute may give future browsers a way to work intelligently with certain XML elements in a device-independent way. For example, an unordered list that is marked with the role attribute of "navigation" can be interpreted intelligently on browsers in both desktop and handheld environments, allowing it to be displayed clearly in both environments.
加長版:
本規范中定義的 XHTML 角色屬性允許作者使用機器可提取的有關元素用途的語義信息來注釋 XML 語言.用例包括可訪問性、設備適配、服務器端處理和復雜數據描述.
The XHTML Role Attribute defined in this specification allows the author to annotate XML Languages with machine-extractable semantic information about the purpose of an element. Use cases include accessibility, device adaptation, server-side processing, and complex data description.
該屬性描述了當前元素在文檔上下文中所扮演的角色.例如,應用程序和輔助技術可以使用它來確定元素的用途.這可以允許用戶做出明智的決定,決定可以對元素采取哪些操作,并以設備獨立方式激活所選操作.它還可以用作以領域特定方式(例如,法律術語分類法)注釋文檔部分的機制.
The attribute describes the role(s) the current element plays in the context of the document. This can be used, for example, by applications and assistive technologies to determine the purpose of an element. This could allow a user to make informed decisions on which actions may be taken on an element and activate the selected action in a device independent way. It could also be used as a mechanism for annotating portions of a document in a domain specific way (e.g., a legal term taxonomy).
例子:
<ul role="navigation sitemap">
<li href="downloads">Downloads</li>
<li href="docs">Documentation</li>
<li href="news">News</li>
</ul>
鑒于 XHTML2 工作組將在今年年底不復存在,因此該規范不可能以類似于其當前形式的任何形式達到發布狀態.http://www.w3.org/News/2009#entry-6601
Given that the XHTML2 Working Group will cease to exist at the end of this year, there's no chance of this specification ever reaching release status in anything resembling its current form. http://www.w3.org/News/2009#entry-6601
這篇關于什么是 XHTML 角色屬性?你用它來做什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!