DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> HTML基礎知識 >> HTML和Xhtml
HTML 不常用標籤 optgroup、sub、sup 與 bdo 的示例解析
編輯:HTML和Xhtml     

有些 HTML 標籤雖然不常被使用,卻在特定場景下非常好用。以下介紹 optgroup、sub、sup 和 bdo 四個標籤的用法。

optgroup:為下拉選單分組

optgroup 用在 select 標籤中,可以讓下拉列表的內容更有條理,透過 label 屬性為選項分組:

<select> <optgroup label="aaa"> <option>選項一</option> </optgroup> <optgroup style="color:#C30" label="bbb"> <option>選項二</option> </optgroup> </select>

sub 與 sup:上標與下標

sub 用於上標,sup 用於下標,兩者都能與 <em> 一起用於註釋說明。例如 X<sub>2</sub> 會呈現為下標效果。

bdo:改變文字輸出方向

bdo(配合 dir 屬性)可以改變文字的輸出方向。使用時必須搭配 dir 屬性:ltr 代表從左到右的編排順序,rtl 代表從右到左的編排順序。例如 <bdo dir="rtl">我非常愛你</bdo> 會以由右至左的方向呈現文字。

以下為完整的示例程式碼,可直接複製運行:

<select> <optgroup label="HTML標記"> <option>table</option> <option>tr</option> </optgroup> <optgroup label="ASP內置對象"> <option>cookies</option> <option>session</option> </optgroup> </select>

<fieldset><legend>sub標記</legend> X<sub>2</sub> 上標 X<sup>2</sup> 下標</fieldset>

<fieldset><legend>bdo標記</legend> <bdo dir="ltr">我非常愛你</bdo> <bdo dir="rtl">你愛常非我</bdo></fieldset>

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved