屬性

  • HTML5 新的全域屬性:contenteditable, contextmenu, draggable, dropzone, hidden, spellcheck。
  • HTML5 新的屬性:ping(用於a與area), charset(用於meta), async(用於script)。

易忽略的 HTML4全域屬性 (global attribute)

Attribute Description
accesskey 熱鍵
dir Specifies the text direction for the content in an element
lang Specifies the language of the element's content
tabindex Specifies the tabbing order of an element

accessKey

  • 熱鍵
  • windown os 可搭配控制鍵 alt,做 focus 位置切換
  • mac os 可搭配控制鍵 ctrol + alt,做 focus 位置切換

解析題庫:1-33, 2-07

Differences Between HTML 4.01 and HTML5 In HTML5, the accesskey attribute can be used on any HTML element (it will validate on any HTML element. However, it is not necessarily useful).

In HTML 4.01, the accesskey attribute can be used with:

<a>, <area>, <button>, <input>, <label>, <legend>, and <textarea>.

http://www.w3schools.com/tags/att_global_accesskey.asp

dir

語法

<element dir="ltr|rtl|auto">

範例

<p dir="rtl">Write this text right-to-left!</p>

屬性值

Value Description
ltr 預設,左到右呈現 (Left-to-right text direction)
rtl 右到左 (Right-to-left text direction)
auto Let the browser figure out the text direction, based on the content (only recommended if the text direction is unknown)

http://www.w3schools.com/tags/att_global_dir.asp

lang

Common examples are "en" for English, "es" for Spanish, "fr" for France and so on.

範例

<p lang="fr">Ceci est un paragraphe.</p>

補充: Differences Between HTML 4.01 and HTML5

In HTML5, the lang attribute can be used on any HTML element (it will validate on any HTML element. However, it is not necessarily useful).

In HTML 4.01, the lang attribute cannot be used with: <base>, <br>, <frame>, <frameset>, <hr>, <iframe>, <param>, <script>

tabindex

定義

The tabindex attribute specifies the tab order of an element (when the "tab" button is used for navigating).

語法

<element tabindex="number">

範例

<a href="http://www.w3schools.com/" tabindex="2">W3Schools</a>
<a href="http://www.google.com/" tabindex="1">Google</a>
<a href="http://www.microsoft.com/" tabindex="3">Microsoft</a>

題庫解析:2-05

http://www.w3schools.com/tags/att_global_tabindex.asp

HTML5 新增的全域屬性

Attribute Description
contenteditable 元素內容可以被編輯
contextmenu Specifies a context menu for an element. The context menu appears when a user right-clicks on the element
data-* Used to store custom data private to the page or application
draggable 設定可拖曳元素
dropzone `拖放區域`
hidden 隱藏元素, Specifies that an element is not yet, or is no longer, relevant
spellcheck Specifies whether the element is to have its spelling and grammar checked or not
translate Specifies whether the content of an element should be translated or not

範例

<p hidden>This paragraph should be hidden.</p>

results matching ""

    No results matching ""