详解HTML5中的

时间:2023-03-08 20:02:07

<aside>元素
HTML<aside>元素表示一个页面的一部分, 它的内容跟这个页面的其它内容的关联性不强,或者是没有关联,单独存在。<aside>元素通常显示成侧边栏(sidebar)或一些插入补充内容。通常用来在侧边栏显示一些定义,比如目录、索引、术语表等;也可以用来显示相关的广告宣传,作者的介绍,Web应用,相关链接,当前页内容简介等。

<aside>元素使用注意事项:

不要使用<aside>元素标记括号中的文字,因为这种类型的文本被认为是主内容的一部分。

使用例子:

XML/HTML Code复制内容到剪贴板
  1. <article>
  2. <p>
  3. The Disney movie <em>The Little Mermaid</em> was
  4. first released to theatres in 1989.
  5. </p>
  6. <aside>
  7. The movie earned $87 million during its initial release.
  8. </aside>
  9. <p>
  10. More info about the movie...
  11. </p>
  12. </article>

<article>元素
Article元素(<article>)故名思议,可以表示论坛帖子、杂志或新闻文章、博客、用户提交的评论、交互式组件,或者其他独立的内容项目。它的主要语义为表示自己是一个独立的内容结构。每一个<article>元素内部结构都应该是相似的,比如都应该包含一个头标题(h1-h6元素)等。

<article>元素用法:

当<article>元素嵌套使用时,则该元素代表与父元素有关的文章。例如,代表博客评论的<article>元素可嵌套在代表博客文章的<article>元素中。
    <article>元素中文章作者的信息可通过<address>元素表示,但是不适用于嵌套的<article>元素。

<article>元素中文章的发布日期和时间可通过<time>元素的pubdate属性表示。

代码样例

XML/HTML Code复制内容到剪贴板
  1. <article class="film_review">
  2. <header>
  3. <h2>侏罗纪公园</h2>
  4. </header>
  5. <section class="main_review">
  6. <p>Dinos were great!</p>
  7. </section>
  8. <section class="user_reviews">
  9. <article class="user_review">
  10. <p>Way too scary for me.</p>
  11. <footer>
  12. <p>
  13. Posted on <time datetime="2015-05-16 19:00">May 16</time> by Lisa.
  14. </p>
  15. </footer>
  16. </article>
  17. <article class="user_review">
  18. <p>I agree, dinos are my favorite.</p>
  19. <footer>
  20. <p>
  21. Posted on <time datetime="2015-05-17 19:00">May 17</time> by Tom.
  22. </p>
  23. </footer>
  24. </article>
  25. </section>
  26. <footer>
  27. <p>
  28. Posted on <time datetime="2015-05-15 19:00">May 15</time> by Staff.
  29. </p>
  30. </footer>
  31. </article>