站长资讯网
最全最丰富的资讯网站

HTML5中的<aside>元素与<article>元素 实例详解

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

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

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

使用例子:

<article>            <p>              The Disney movie <em>The Little Mermaid</em> was               first released to theatres in 1989.             </p>            <aside>              The movie earned $87 million during its initial release.             </aside>            <p>              More info about the movie...             </p>          </article>

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

<article>元素用法:

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

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

代码样例

<article class="film_review">            <header>              <h2>侏罗纪公园</h2>            </header>            <section class="main_review">              <p>Dinos were great!</p>            </section>            <section class="user_reviews">              <article class="user_review">                <p>Way too scary for me.</p>                <footer>                  <p>                    Posted on <time datetime="2015-05-16 19:00">May 16</time> by Lisa.                   </p>                </footer>              </article>              <article class="user_review">                <p>I agree, dinos are my favorite.</p>                <footer>                  <p>                    Posted on <time datetime="2015-05-17 19:00">May 17</time> by Tom.                   </p>                </footer>              </article>            </section>            <footer>              <p>                Posted on <time datetime="2015-05-15 19:00">May 15</time> by Staff.               </p>            </footer>          </article>

赞(0)
分享到: 更多 (0)