HTML 5深入浅出教学篇之二

开发 前端
本文主要讲到的是区块元素 - body, article, section, header, footer, h1, h2, h3, h4, h5, h6, hgroup, aside, nav, address。

介绍

HTML 5: 区块元素

区块元素 - body, article, section, header, footer, h1, h2, h3, h4, h5, h6, hgroup, aside, nav, address

示例

1、body - 用于定义文档的主体element/section/body.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>body</title> 
  5. </head> 
  6.  
  7. <!--  
  8.     body - 用于定义文档的主体。其相关事件处理属性如下  
  9. --> 
  10. <body> 
  11.     <script type="text/javascript" defer> 
  12.         var body = document.body;  
  13.  
  14.         body.onafterprint = function () { alert("onafterprint"); };  
  15.         body.onbeforeprint = function () { alert("onbeforeprint"); };  
  16.         body.onbeforeunload = function () { alert("onbeforeunload"); };  
  17.         body.onblur = function () { alert("onblur"); };  
  18.         body.onerror = function () { alert("onerror"); };  
  19.         body.onfocus = function () { alert("onfocus"); };  
  20.         body.onhashchange = function () { alert("onhashchange"); };  
  21.         body.onload = function () { alert("onload"); };  
  22.         body.onmessage = function () { alert("onmessage"); };  
  23.         body.onoffline = function () { alert("onoffline"); };  
  24.         body.ononline = function () { alert("ononline"); };  
  25.         body.onpagehide = function () { alert("onpagehide"); };  
  26.         body.onpageshow = function () { alert("onpageshow"); };  
  27.         body.onpopstate = function () { alert("onpopstate"); };  
  28.         body.onresize = function () { alert("onresize"); };  
  29.         body.onscroll = function () { alert("onscroll"); };  
  30.         body.onstorage = function () { alert("onstorage"); };  
  31.         body.onunload = function () { alert("onunload"); };  
  32.     </script> 
  33. </body> 
  34. </html> 

2、article - 用于定义一段完整且独立的内容element/section/article.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>article</title> 
  5. </head> 
  6. <body> 
  7.     <!--  
  8.         article - 用于定义一段完整且独立的内容  
  9.     --> 
  10.     <article> 
  11.         我是一段完整且独立的内容  
  12.     </article> 
  13. </body> 
  14. </html> 

3、section - 用于定义文档内容中的某一部分element/section/section.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>section</title> 
  5. </head> 
  6. <body> 
  7.     <article> 
  8.         <!--  
  9.             section - 用于定义文档内容中的某一部分  
  10.         --> 
  11.         <section>我要学习 html5</section> 
  12.         <section>我要学习 flash</section> 
  13.         <section>我要学习 silverlight</section> 
  14.     </article> 
  15. </body> 
  16. </html> 

4、header - 定义文档的页眉element/section/header.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>header</title> 
  5. </head> 
  6. <body> 
  7.     <article> 
  8.         <!--  
  9.             header - 定义文档的页眉  
  10.         --> 
  11.         <header>学什么呢?</header> 
  12.         <section>我要学习 html5</section> 
  13.         <section>我要学习 flash</section> 
  14.         <section>我要学习 silverlight</section> 
  15.     </article> 
  16. </body> 
  17. </html> 

5、footer - 定义文档的页脚element/section/footer.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>footer</title> 
  5. </head> 
  6. <body> 
  7.     <article> 
  8.         <header>学什么呢?</header> 
  9.         <section>我要学习 html5</section> 
  10.         <section>我要学习 flash</section> 
  11.         <section>我要学习 silverlight</section> 
  12.         <!--  
  13.             footer - 定义文档的页脚  
  14.         --> 
  15.         <footer>作者:webabcd</footer> 
  16.     </article> 
  17. </body> 
  18. </html> 

6、h1 h2 h3 h4 h5 h6 - 用于定义 6 种不同级别的标题,h1 为最大标题,h6 为最小标题element/section/h1_h2_h3_h4_h5_h6.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>h1 h2 h3 h4 h5 h6</title> 
  5. </head> 
  6. <body> 
  7.     <article> 
  8.         <header> 
  9.             <!--  
  10.                 h1 h2 h3 h4 h5 h6 - 用于定义 6 种不同级别的标题,h1 为最大标题,h6 为最小标题  
  11.             --> 
  12.             <h6>学什么呢?</h6> 
  13.         </header> 
  14.         <section>我要学习 html5</section> 
  15.         <section>我要学习 flash</section> 
  16.         <section>我要学习 silverlight</section> 
  17.         <footer>作者:webabcd</footer> 
  18.     </article> 
  19. </body> 
  20. </html> 

7、hgroup - 用于对文档某段内容的标题进行组合,使用 h1 h2 h3 h4 h5 h6 来标记标题的级别element/section/hgroup.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>hgroup</title> 
  5. </head> 
  6. <body> 
  7.     <article> 
  8.         <header> 
  9.             <h6> 
  10.                 学什么呢?  
  11.             </h6> 
  12.         </header> 
  13.         <!--  
  14.             hgroup - 用于对文档某段内容的标题进行组合,使用 h1 h2 h3 h4 h5 h6 来标记标题的级别  
  15.         --> 
  16.         <hgroup> 
  17.             <h1>webabcd 文章</h1> 
  18.             <h2>谈谈学习</h2> 
  19.         </hgroup> 
  20.         <section>我要学习 html5</section> 
  21.         <section>我要学习 flash</section> 
  22.         <section>我要学习 silverlight</section> 
  23.         <footer>作者:webabcd</footer> 
  24.     </article> 
  25. </body> 
  26. </html> 

8、aside - 用于定义文档以外的,但却与文档相关的内容element/section/aside.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>aside</title> 
  5. </head> 
  6. <body> 
  7.     <article> 
  8.         <header> 
  9.             <h6> 
  10.                 学什么呢?  
  11.             </h6> 
  12.         </header> 
  13.         <hgroup> 
  14.             <h1>webabcd 文章</h1> 
  15.             <h2>谈谈学习</h2> 
  16.         </hgroup> 
  17.         <section>我要学习 html5</section> 
  18.         <section>我要学习 flash</section> 
  19.         <section>我要学习 silverlight</section> 
  20.         <footer>作者:webabcd</footer> 
  21.         <!--  
  22.             aside - 用于定义文档以外的,但却与文档相关的内容  
  23.         --> 
  24.         <aside> 
  25.             我还写了好多其他文章  
  26.         </aside> 
  27.     </article> 
  28. </body> 
  29. </html> 

9、nav - 用于定义导航链接(nav 是 navigation 的缩写)element/section/nav.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>nav</title> 
  5. </head> 
  6. <body> 
  7.     <article> 
  8.         <header> 
  9.             <h6> 
  10.                 学什么呢?  
  11.             </h6> 
  12.         </header> 
  13.         <hgroup> 
  14.             <h1>webabcd 文章</h1> 
  15.             <h2>谈谈学习</h2> 
  16.         </hgroup> 
  17.         <section>我要学习 html5</section> 
  18.         <section>我要学习 flash</section> 
  19.         <section>我要学习 silverlight</section> 
  20.         <footer>作者:webabcd</footer> 
  21.         <aside> 
  22.             <!--  
  23.                 nav - 用于定义导航链接(nav 是 navigation 的缩写)  
  24.             --> 
  25.             <nav><a href="http://webabcd.cnblogs.com/" target="_blank">我还写了好多其他文章,单击这里查看</a></nav> 
  26.         </aside> 
  27.     </article> 
  28. </body> 
  29. </html> 

10、address - 定义文档作者的联系信息element/section/address.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>address</title> 
  5. </head> 
  6. <body> 
  7.     <article> 
  8.         <header> 
  9.             <h6> 
  10.                 学什么呢?  
  11.             </h6> 
  12.         </header> 
  13.         <hgroup> 
  14.             <h1>webabcd 文章</h1> 
  15.             <h2>谈谈学习</h2> 
  16.         </hgroup> 
  17.         <section>我要学习 html5</section> 
  18.         <section>我要学习 flash</section> 
  19.         <section>我要学习 silverlight</section> 
  20.         <footer> 
  21.             <!--  
  22.                 address - 定义文档作者的联系信息  
  23.             --> 
  24.             <address> 
  25.                 作者:webabcd,我的电话:911  
  26.             </address> 
  27.         </footer> 
  28.         <aside> 
  29.             <nav><a href="http://webabcd.cnblogs.com/" target="_blank">我还写了好多其他文章,单击这里查看</a></nav> 
  30.         </aside> 
  31.     </article> 
  32. </body> 
  33. </html> 

[源码下载]

原文链接:http://www.cnblogs.com/webabcd/archive/2011/09/19/2180990.html

责任编辑:张伟 来源: webabcd的博客
相关推荐

2012-05-31 09:35:43

HTML5

2012-05-30 15:17:54

HTML5

2012-05-31 10:57:06

HTML5

2012-05-30 13:26:12

HTML5

2012-05-31 09:54:13

HTML5

2012-05-30 13:49:52

HTML5

2012-05-30 14:51:09

HTML5

2012-05-30 13:17:46

HTML5

2012-05-31 09:19:22

HTML5

2012-05-30 10:52:09

HTML5

2016-10-14 14:32:58

JavascriptDOMWeb

2022-02-25 08:54:50

setState异步React

2021-03-16 08:54:35

AQSAbstractQueJava

2011-07-04 10:39:57

Web

2019-01-07 15:29:07

HadoopYarn架构调度器

2021-07-20 15:20:02

FlatBuffers阿里云Java

2017-07-02 18:04:53

块加密算法AES算法

2012-05-21 10:06:26

FrameworkCocoa

2012-02-07 15:29:17

Android核心组件Service

2022-09-26 09:01:15

语言数据JavaScript
点赞
收藏

51CTO技术栈公众号