溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

HTML5中語義性的塊級(jí)元素有哪些

發(fā)布時(shí)間:2021-10-14 15:35:55 來源:億速云 閱讀:130 作者:小新 欄目:web開發(fā)

這篇文章給大家分享的是有關(guān)HTML5中語義性的塊級(jí)元素有哪些的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。

HTML5還增加了一些純語義性的塊級(jí)元素:
  aside  figure  dialog
  我在文章和書中一直使用前兩個(gè)元素。第三個(gè)元素我不經(jīng)常用,它主要用于書面文本。
aside
  aside元素代表說明、提示、邊欄、引用、附加注釋等,也就是敘述主線之外的內(nèi)容。例如,在developerWorks文章中,常常會(huì)看到用表格形式編寫的邊欄,見代碼3用HTML4編寫的developerWorks邊欄。
<tablealign="right"border="0"cellpadding="0"cellspacing="0"width="40%">
<tbody><tr><tdwidth="10">
<imgalt=""src="//www.ibm.com/i/c.gif"height="1"width="10"></td>
<td>
<tableborder="1"cellpadding="5"cellspacing="0"width="100%">
<tbody><tr><tdbgcolor="#eeeeee">
<p><aname="xf-value"><spanclass="smalltitle">.xf-value</span></a></p>
<p>
The<codetype="inline">.xf-value</code>selectorusedherestylestheinput
fieldvaluebutnotitslabel.Thisisactuallyinconsistent
withthecurrentCSS3draft.Theexamplereallyshouldusethe
<codetype="inline">::value</code>pseudo-classinsteadlikeso:
</p>
<tableborder="0"cellpadding="0"cellspacing="0"width="100%">
<tbody><tr><tdclass="code-outline">
<preclass="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,Firefoxdoesn'tyetsupportthissyntax.
</p>
</td></tr></table>
  在HTML5中,可以按照更有意義的方式編寫這個(gè)邊欄,見代碼4用HTML5編寫的developerWorks邊欄。
<aside>
<h4>.xf-value</h4>
<p>
The<codetype="inline">.xf-value</code>selectorusedherestylestheinput
fieldvaluebutnotitslabel.Thisisactuallyinconsistent
withthecurrentCSS3draft.Theexamplereallyshouldusethe
<codetype="inline">::value</code>pseudo-classinsteadlikeso:
</p>

<preclass="displaycode">input::value{width:20em;}
#ccnumber::value{width:18em}
#zip::value{width:12em}
#state::value{width:3em}</pre>
<p>
However,Firefoxdoesn'tyetsupportthissyntax.
</p>
</aside>

  瀏覽器可以決定把這個(gè)邊欄放在哪里(可能需要用一點(diǎn)兒CSS代碼)。
figure
  figure元素代表一個(gè)塊級(jí)圖像,還可以包含說明。例如,在許多developerWorks文章中,可以看到代碼5用HTML4編寫的developerWorks圖這樣的標(biāo)記其結(jié)果見圖1。
<aname="fig2"><b>Figure2.InstallMozillaXFormsdialog</b></a><br/>
<imgalt="AWebsiteisrequestingpermissiontoinstallthefollowingitem:
MozillaXForms0.7Unsigned"
src="installdialog.jpg"border="0"height="317"hspace="5"vspace="5"width="331"/>
<br/>

圖1.InstallMozillaXFormsdialog
HTML5中語義性的塊級(jí)元素有哪些
  在HTML5中,可以按照更有語義性的方式編寫這個(gè)圖,見代碼6用HTML5編寫的developerWorks圖。
<figureid="fig2">
<legend>Figure2.InstallMozillaXFormsdialog</legend>
<imgalt="AWebsiteisrequestingpermissiontoinstallthefollowingitem:
MozillaXForms0.7Unsigned"
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ì)話。HTML5dt元素可以表示講話者,HTML5dd元素可以表示講話內(nèi)容。所以,在老式瀏覽器中也可以以合理的方式顯示對(duì)話。代碼7顯示在Galileo的“DialogueConcerningtheTwoChiefWorldSystems”上的一段著名對(duì)話。
  代碼7.用HTML5編寫的Galilean對(duì)話
<dialog>
<dt>Simplicius</dt>
<dd>AccordingtothestraightlineAF,
andnotaccordingtothecurve,suchbeingalreadyexcluded
forsuchause.</dd>
<dt>Sagredo</dt>
<dd>ButIshouldtakeneitherofthem,
seeingthatthestraightlineAFrunsobliquely.Ishould
drawalineperpendiculartoCD,forthiswouldseemtome
tobetheshortest,aswellasbeinguniqueamongthe
infinitenumberoflongerandunequaloneswhichmaybe
drawnfromthepointAtoeveryotherpointoftheopposite
lineCD.</dd>
<dt>Salviati</dt>
<dd><p>Yourchoiceandthereasonyou
adduceforitseemtomemostexcellent.Sonowwehaveit
thatthefirstdimensionisdeterminedbyastraightline;
thesecond(namely,breadth)byanotherstraightline,and
notonlystraight,butatrightanglestothatwhich
determinesthelength.Thuswehavedefinedthetwo
dimensionsofasurface;thatis,lengthandbreadth.</p>
<p>Butsupposeyouhadtodetermineaheight&mdash;for
example,howhighthisplatformisfromthepavementdown
belowthere.Seeingthatfromanypointintheplatformwe
maydrawinfinitelines,curvedorstraight,andallof
differentlengths,totheinfinitepointsofthepavement
below,whichofalltheselineswouldyoumakeuseof?</p>
</dd>
</dialog>
  對(duì)于這個(gè)元素的準(zhǔn)確語法還有爭議。一些人希望在dialog元素中嵌入非對(duì)話文本(比如劇本中的舞臺(tái)說明),還有人不喜歡擴(kuò)展dt和dd元素的作用。盡管在具體語法方面有爭議,但是大多數(shù)人都認(rèn)為以這樣的語義性方式表達(dá)對(duì)話是好事情。

感謝各位的閱讀!關(guān)于“HTML5中語義性的塊級(jí)元素有哪些”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI