HTML 5深入淺出教學(xué)篇之二
介紹
HTML 5: 區(qū)塊元素
區(qū)塊元素 - body, article, section, header, footer, h1, h2, h3, h4, h5, h6, hgroup, aside, nav, address
示例
1、body - 用于定義文檔的主體element/section/body.html
- <!doctype html>
- <html>
- <head>
- <title>body</title>
- </head>
- <!--
- body - 用于定義文檔的主體。其相關(guān)事件處理屬性如下
- -->
- <body>
- <script type="text/javascript" defer>
- var body = document.body;
- body.onafterprint = function () { alert("onafterprint"); };
- body.onbeforeprint = function () { alert("onbeforeprint"); };
- body.onbeforeunload = function () { alert("onbeforeunload"); };
- body.onblur = function () { alert("onblur"); };
- body.onerror = function () { alert("onerror"); };
- body.onfocus = function () { alert("onfocus"); };
- body.onhashchange = function () { alert("onhashchange"); };
- body.onload = function () { alert("onload"); };
- body.onmessage = function () { alert("onmessage"); };
- body.onoffline = function () { alert("onoffline"); };
- body.ononline = function () { alert("ononline"); };
- body.onpagehide = function () { alert("onpagehide"); };
- body.onpageshow = function () { alert("onpageshow"); };
- body.onpopstate = function () { alert("onpopstate"); };
- body.onresize = function () { alert("onresize"); };
- body.onscroll = function () { alert("onscroll"); };
- body.onstorage = function () { alert("onstorage"); };
- body.onunload = function () { alert("onunload"); };
- </script>
- </body>
- </html>
2、article - 用于定義一段完整且獨(dú)立的內(nèi)容element/section/article.html
- <!doctype html>
- <html>
- <head>
- <title>article</title>
- </head>
- <body>
- <!--
- article - 用于定義一段完整且獨(dú)立的內(nèi)容
- -->
- <article>
- 我是一段完整且獨(dú)立的內(nèi)容
- </article>
- </body>
- </html>
3、section - 用于定義文檔內(nèi)容中的某一部分element/section/section.html
- <!doctype html>
- <html>
- <head>
- <title>section</title>
- </head>
- <body>
- <article>
- <!--
- section - 用于定義文檔內(nèi)容中的某一部分
- -->
- <section>我要學(xué)習(xí) html5</section>
- <section>我要學(xué)習(xí) flash</section>
- <section>我要學(xué)習(xí) silverlight</section>
- </article>
- </body>
- </html>
4、header - 定義文檔的頁(yè)眉element/section/header.html
- <!doctype html>
- <html>
- <head>
- <title>header</title>
- </head>
- <body>
- <article>
- <!--
- header - 定義文檔的頁(yè)眉
- -->
- <header>學(xué)什么呢?</header>
- <section>我要學(xué)習(xí) html5</section>
- <section>我要學(xué)習(xí) flash</section>
- <section>我要學(xué)習(xí) silverlight</section>
- </article>
- </body>
- </html>
5、footer - 定義文檔的頁(yè)腳element/section/footer.html
- <!doctype html>
- <html>
- <head>
- <title>footer</title>
- </head>
- <body>
- <article>
- <header>學(xué)什么呢?</header>
- <section>我要學(xué)習(xí) html5</section>
- <section>我要學(xué)習(xí) flash</section>
- <section>我要學(xué)習(xí) silverlight</section>
- <!--
- footer - 定義文檔的頁(yè)腳
- -->
- <footer>作者:webabcd</footer>
- </article>
- </body>
- </html>
6、h1 h2 h3 h4 h5 h6 - 用于定義 6 種不同級(jí)別的標(biāo)題,h1 為最大標(biāo)題,h6 為最小標(biāo)題element/section/h1_h2_h3_h4_h5_h6.html
- <!doctype html>
- <html>
- <head>
- <title>h1 h2 h3 h4 h5 h6</title>
- </head>
- <body>
- <article>
- <header>
- <!--
- h1 h2 h3 h4 h5 h6 - 用于定義 6 種不同級(jí)別的標(biāo)題,h1 為最大標(biāo)題,h6 為最小標(biāo)題
- -->
- <h6>學(xué)什么呢?</h6>
- </header>
- <section>我要學(xué)習(xí) html5</section>
- <section>我要學(xué)習(xí) flash</section>
- <section>我要學(xué)習(xí) silverlight</section>
- <footer>作者:webabcd</footer>
- </article>
- </body>
- </html>
7、hgroup - 用于對(duì)文檔某段內(nèi)容的標(biāo)題進(jìn)行組合,使用 h1 h2 h3 h4 h5 h6 來標(biāo)記標(biāo)題的級(jí)別element/section/hgroup.html
- <!doctype html>
- <html>
- <head>
- <title>hgroup</title>
- </head>
- <body>
- <article>
- <header>
- <h6>
- 學(xué)什么呢?
- </h6>
- </header>
- <!--
- hgroup - 用于對(duì)文檔某段內(nèi)容的標(biāo)題進(jìn)行組合,使用 h1 h2 h3 h4 h5 h6 來標(biāo)記標(biāo)題的級(jí)別
- -->
- <hgroup>
- <h1>webabcd 文章</h1>
- <h2>談?wù)剬W(xué)習(xí)</h2>
- </hgroup>
- <section>我要學(xué)習(xí) html5</section>
- <section>我要學(xué)習(xí) flash</section>
- <section>我要學(xué)習(xí) silverlight</section>
- <footer>作者:webabcd</footer>
- </article>
- </body>
- </html>
8、aside - 用于定義文檔以外的,但卻與文檔相關(guān)的內(nèi)容element/section/aside.html
- <!doctype html>
- <html>
- <head>
- <title>aside</title>
- </head>
- <body>
- <article>
- <header>
- <h6>
- 學(xué)什么呢?
- </h6>
- </header>
- <hgroup>
- <h1>webabcd 文章</h1>
- <h2>談?wù)剬W(xué)習(xí)</h2>
- </hgroup>
- <section>我要學(xué)習(xí) html5</section>
- <section>我要學(xué)習(xí) flash</section>
- <section>我要學(xué)習(xí) silverlight</section>
- <footer>作者:webabcd</footer>
- <!--
- aside - 用于定義文檔以外的,但卻與文檔相關(guān)的內(nèi)容
- -->
- <aside>
- 我還寫了好多其他文章
- </aside>
- </article>
- </body>
- </html>
9、nav - 用于定義導(dǎo)航鏈接(nav 是 navigation 的縮寫)element/section/nav.html
- <!doctype html>
- <html>
- <head>
- <title>nav</title>
- </head>
- <body>
- <article>
- <header>
- <h6>
- 學(xué)什么呢?
- </h6>
- </header>
- <hgroup>
- <h1>webabcd 文章</h1>
- <h2>談?wù)剬W(xué)習(xí)</h2>
- </hgroup>
- <section>我要學(xué)習(xí) html5</section>
- <section>我要學(xué)習(xí) flash</section>
- <section>我要學(xué)習(xí) silverlight</section>
- <footer>作者:webabcd</footer>
- <aside>
- <!--
- nav - 用于定義導(dǎo)航鏈接(nav 是 navigation 的縮寫)
- -->
- <nav><a href="http://webabcd.cnblogs.com/" target="_blank">我還寫了好多其他文章,單擊這里查看</a></nav>
- </aside>
- </article>
- </body>
- </html>
10、address - 定義文檔作者的聯(lián)系信息element/section/address.html
- <!doctype html>
- <html>
- <head>
- <title>address</title>
- </head>
- <body>
- <article>
- <header>
- <h6>
- 學(xué)什么呢?
- </h6>
- </header>
- <hgroup>
- <h1>webabcd 文章</h1>
- <h2>談?wù)剬W(xué)習(xí)</h2>
- </hgroup>
- <section>我要學(xué)習(xí) html5</section>
- <section>我要學(xué)習(xí) flash</section>
- <section>我要學(xué)習(xí) silverlight</section>
- <footer>
- <!--
- address - 定義文檔作者的聯(lián)系信息
- -->
- <address>
- 作者:webabcd,我的電話:911
- </address>
- </footer>
- <aside>
- <nav><a href="http://webabcd.cnblogs.com/" target="_blank">我還寫了好多其他文章,單擊這里查看</a></nav>
- </aside>
- </article>
- </body>
- </html>
原文鏈接:http://www.cnblogs.com/webabcd/archive/2011/09/19/2180990.html