HTML5的結(jié)構(gòu)和語義——語義性的塊級(jí)元素(三)_XHTML教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
HTML 5 還增加了一些純語義性的塊級(jí)元素:
aside figure dialog
我在文章和書中一直使用前兩個(gè)元素。第三個(gè)元素我不經(jīng)常用,它主要用于書面文本。
aside
aside 元素代表說明、提示、邊欄、引用、附加注釋等,也就是敘述主線之外的內(nèi)容。例如,在 developerWorks 文章中,經(jīng)常會(huì)看到用表格形式編寫的邊欄,見代碼3 用 HTML 4 編寫的 developerWorks 邊欄。
在 HTML 5 中,可以按照更有意義的方式編寫這個(gè)邊欄,見代碼4 用 HTML 5 編寫的 developerWorks 邊欄。
瀏覽器可以決定把這個(gè)邊欄放在哪里(可能需要用一點(diǎn)兒 CSS 代碼)。
figure
figure 元素代表一個(gè)塊級(jí)圖像,還可以包含說明。例如,在許多 developerWorks 文章中,可以看到代碼5 用 HTML 4 編寫的 developerWorks 圖 這樣的標(biāo)記其結(jié)果見圖1。
在 HTML 5 中,可以按照更有語義性的方式編寫這個(gè)圖,見代碼6 用 HTML 5 編寫的 developerWorks 圖。
最重要的是,瀏覽器(尤其是屏幕閱讀器)可以明確地將圖和說明聯(lián)系在一起。
figure 元素不只可以顯示圖片。還可以使用它給 audio、video、iframe、object 和 embed 元素加說明。
dialog
dialog 元素表示幾個(gè)人之間的對(duì)話。HTML 5 dt 元素可以表示講話者,HTML 5 dd 元素可以表示講話內(nèi)容。所以,在老式瀏覽器中也可以以合理的方式顯示對(duì)話。代碼7 顯示在 Galileo 的 “Dialogue Concerning the Two Chief World Systems” 上的一段聞名對(duì)話。
代碼7. 用 HTML 5 編寫的 Galilean 對(duì)話
對(duì)于這個(gè)元素的準(zhǔn)確語法還有爭(zhēng)議。一些人希望在 dialog 元素中嵌入非對(duì)話文本(比如劇本中的舞臺(tái)說明),還有人不喜歡擴(kuò)展 dt 和 dd 元素的作用。盡管在具體語法方面有爭(zhēng)議,但是大多數(shù)人都認(rèn)為以這樣的語義性方式表達(dá)對(duì)話是好事情。
(待續(xù))
aside figure dialog
我在文章和書中一直使用前兩個(gè)元素。第三個(gè)元素我不經(jīng)常用,它主要用于書面文本。
aside
aside 元素代表說明、提示、邊欄、引用、附加注釋等,也就是敘述主線之外的內(nèi)容。例如,在 developerWorks 文章中,經(jīng)常會(huì)看到用表格形式編寫的邊欄,見代碼3 用 HTML 4 編寫的 developerWorks 邊欄。
示例代碼 [www.hl5o.cn]
<table align="right" border="0" cellpadding="0" cellspacing="0" width="40%">
<tbody><tr><td width="10">
<img alt="" src="http://www.ibm.com/i/c.gif" height="1" width="10"></td>
<td>
<table border="1" cellpadding="5" cellspacing="0" width="100%">
<tbody><tr><td bgcolor="#eeeeee">
<p><a name="xf-value"><span class="smalltitle">.xf-value</span></a></p>
<p>
The <code type="inline">.xf-value</code> selector used here styles the input
field value but not its label. This is actually inconsistent
with the current CSS3 draft. The example really should use the
<code type="inline">::value</code> pseudo-class instead like so:
</p>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr><td class="code-outline">
<pre class="displaycode">input::value { width: 20em; }
#ccnumber::value { width: 18em }
#zip::value { width: 12em }
#state::value { width: 3em }</pre>
</td></tr></tbody></table><br>
<p>
However, Firefox doesn't yet support this syntax.
</p>
</td></tr></table>
<tbody><tr><td width="10">
<img alt="" src="http://www.ibm.com/i/c.gif" height="1" width="10"></td>
<td>
<table border="1" cellpadding="5" cellspacing="0" width="100%">
<tbody><tr><td bgcolor="#eeeeee">
<p><a name="xf-value"><span class="smalltitle">.xf-value</span></a></p>
<p>
The <code type="inline">.xf-value</code> selector used here styles the input
field value but not its label. This is actually inconsistent
with the current CSS3 draft. The example really should use the
<code type="inline">::value</code> pseudo-class instead like so:
</p>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr><td class="code-outline">
<pre class="displaycode">input::value { width: 20em; }
#ccnumber::value { width: 18em }
#zip::value { width: 12em }
#state::value { width: 3em }</pre>
</td></tr></tbody></table><br>
<p>
However, Firefox doesn't yet support this syntax.
</p>
</td></tr></table>
在 HTML 5 中,可以按照更有意義的方式編寫這個(gè)邊欄,見代碼4 用 HTML 5 編寫的 developerWorks 邊欄。
示例代碼 [www.hl5o.cn]
<aside>
<h3>.xf-value</h3>
<p>
The <code type="inline">.xf-value</code> selector used here styles the input
field value but not its label. This is actually inconsistent
with the current CSS3 draft. The example really should use the
<code type="inline">::value</code> pseudo-class instead like so:
</p>
<pre class="displaycode">input::value { width: 20em; }
#ccnumber::value { width: 18em }
#zip::value { width: 12em }
#state::value { width: 3em }</pre>
<p>
However, Firefox doesn't yet support this syntax.
</p>
</aside>
<h3>.xf-value</h3>
<p>
The <code type="inline">.xf-value</code> selector used here styles the input
field value but not its label. This is actually inconsistent
with the current CSS3 draft. The example really should use the
<code type="inline">::value</code> pseudo-class instead like so:
</p>
<pre class="displaycode">input::value { width: 20em; }
#ccnumber::value { width: 18em }
#zip::value { width: 12em }
#state::value { width: 3em }</pre>
<p>
However, Firefox doesn't yet support this syntax.
</p>
</aside>
瀏覽器可以決定把這個(gè)邊欄放在哪里(可能需要用一點(diǎn)兒 CSS 代碼)。
figure
figure 元素代表一個(gè)塊級(jí)圖像,還可以包含說明。例如,在許多 developerWorks 文章中,可以看到代碼5 用 HTML 4 編寫的 developerWorks 圖 這樣的標(biāo)記其結(jié)果見圖1。
示例代碼 [www.hl5o.cn]
<a name="fig2"><b>Figure 2. Install Mozilla XForms dialog</b></a><br />
<img alt="A Web site is requesting permission to install the following item:
Mozilla XForms 0.7 Unsigned"
src="installdialog.jpg" border="0" height="317" hspace="5" vspace="5" width="331" />
<br />
<img alt="A Web site is requesting permission to install the following item:
Mozilla XForms 0.7 Unsigned"
src="installdialog.jpg" border="0" height="317" hspace="5" vspace="5" width="331" />
<br />
圖 1. Install Mozilla XForms dialog


在 HTML 5 中,可以按照更有語義性的方式編寫這個(gè)圖,見代碼6 用 HTML 5 編寫的 developerWorks 圖。
示例代碼 [www.hl5o.cn]
<figure id="fig2">
<legend>Figure 2. Install Mozilla XForms dialog</legend>
<img alt="A Web site is requesting permission to install the following item:
Mozilla XForms 0.7 Unsigned"
src="installdialog.jpg" border="0" height="317" hspace="5" vspace="5" width="331" />
</figure>
<legend>Figure 2. Install Mozilla XForms dialog</legend>
<img alt="A Web site is requesting permission to install the following item:
Mozilla XForms 0.7 Unsigned"
src="installdialog.jpg" border="0" height="317" hspace="5" vspace="5" width="331" />
</figure>
最重要的是,瀏覽器(尤其是屏幕閱讀器)可以明確地將圖和說明聯(lián)系在一起。
figure 元素不只可以顯示圖片。還可以使用它給 audio、video、iframe、object 和 embed 元素加說明。
dialog
dialog 元素表示幾個(gè)人之間的對(duì)話。HTML 5 dt 元素可以表示講話者,HTML 5 dd 元素可以表示講話內(nèi)容。所以,在老式瀏覽器中也可以以合理的方式顯示對(duì)話。代碼7 顯示在 Galileo 的 “Dialogue Concerning the Two Chief World Systems” 上的一段聞名對(duì)話。
代碼7. 用 HTML 5 編寫的 Galilean 對(duì)話
示例代碼 [www.hl5o.cn]
<dialog>
<dt>Simplicius </dt>
<dd>According to the straight line AF,
and not according to the curve, such being already excluded
for such a use.</dd>
<dt>Sagredo </dt>
<dd>But I should take neither of them,
seeing that the straight line AF runs obliquely. I should
draw a line perpendicular to CD, for this would seem to me
to be the shortest, as well as being unique among the
infinite number of longer and unequal ones which may be
drawn from the point A to every other point of the opposite
line CD. </dd>
<dt>Salviati </dt>
<dd><p> Your choice and the reason you
adduce for it seem to me most excellent. So now we have it
that the first dimension is determined by a straight line;
the second (namely, breadth) by another straight line, and
not only straight, but at right angles to that which
determines the length. Thus we have defined the two
dimensions of a surface; that is, length and breadth. </p>
<p> But suppose you had to determine a height—for
example, how high this platform is from the pavement down
below there. Seeing that from any point in the platform we
may draw infinite lines, curved or straight, and all of
different lengths, to the infinite points of the pavement
below, which of all these lines would you make use of? </p>
</dd>
</dialog>
<dt>Simplicius </dt>
<dd>According to the straight line AF,
and not according to the curve, such being already excluded
for such a use.</dd>
<dt>Sagredo </dt>
<dd>But I should take neither of them,
seeing that the straight line AF runs obliquely. I should
draw a line perpendicular to CD, for this would seem to me
to be the shortest, as well as being unique among the
infinite number of longer and unequal ones which may be
drawn from the point A to every other point of the opposite
line CD. </dd>
<dt>Salviati </dt>
<dd><p> Your choice and the reason you
adduce for it seem to me most excellent. So now we have it
that the first dimension is determined by a straight line;
the second (namely, breadth) by another straight line, and
not only straight, but at right angles to that which
determines the length. Thus we have defined the two
dimensions of a surface; that is, length and breadth. </p>
<p> But suppose you had to determine a height—for
example, how high this platform is from the pavement down
below there. Seeing that from any point in the platform we
may draw infinite lines, curved or straight, and all of
different lengths, to the infinite points of the pavement
below, which of all these lines would you make use of? </p>
</dd>
</dialog>
對(duì)于這個(gè)元素的準(zhǔn)確語法還有爭(zhēng)議。一些人希望在 dialog 元素中嵌入非對(duì)話文本(比如劇本中的舞臺(tái)說明),還有人不喜歡擴(kuò)展 dt 和 dd 元素的作用。盡管在具體語法方面有爭(zhēng)議,但是大多數(shù)人都認(rèn)為以這樣的語義性方式表達(dá)對(duì)話是好事情。
(待續(xù))
相關(guān)XHTML教程:
- HTML5 INPUT placeholder及兼容性處理
- HTML表單里的Label標(biāo)簽
- 淺析HTML與javascript中常用編碼
- CSS網(wǎng)頁布局中必須要了解的幾個(gè)XHTML標(biāo)簽
- title和alt 標(biāo)簽介紹及其異同
- 淺析HTML標(biāo)簽strong和em的區(qū)別
- 說說XHTML中的alt屬性和title屬性
- Semantics語義是Html Xhtml是否真正符合標(biāo)準(zhǔn)的重要部分
- 九個(gè)W3C XHTML1.0及CSS標(biāo)準(zhǔn)認(rèn)證需要注意的問題
- 請(qǐng)注意頁面head區(qū)域的編碼是不是規(guī)范
- HTML validate - 驗(yàn)證HTML代碼穿越多重瀏覽器標(biāo)準(zhǔn)
- XHTML具有語義的標(biāo)簽:有關(guān)H1位置的討論
XHTML教程Rss訂閱Div+Css教程搜索
XHTML教程推薦
- HTML網(wǎng)頁META標(biāo)簽內(nèi)容寫作規(guī)范要點(diǎn)
- HTML表格標(biāo)記教程(40):表頭的暗邊框色屬性BORDERCOLORDARK
- XHTML三種文件類型聲明
- XHTML入門學(xué)習(xí)教程:網(wǎng)頁Head和DTD
- 請(qǐng)注意頁面head區(qū)域的編碼是不是規(guī)范
- HTML網(wǎng)頁列表標(biāo)記學(xué)習(xí)教程
- HTML表單標(biāo)記教程(5):文字域標(biāo)記
- HTML表格標(biāo)記教程(3):寬度和高度屬性WIDTH、HEIGHT
- xthml的基礎(chǔ)問答
- HTML表單標(biāo)記教程(2):
- 相關(guān)鏈接:
- 教程說明:
XHTML教程-HTML5的結(jié)構(gòu)和語義——語義性的塊級(jí)元素(三)
。