[HTML5]HTML结构性元素(Structure)

参考自:http://techbrood.com/h5b2a?p=html-structure

结构性元素用来组织文档的各个部分

为了让文档层次分明,我们可以把文档中的元素按其内容的作用进行组合,这就需要使用到一些HTML结构性元素。 共有4种HTML结构性元素(structural HTML elements)可以使用。

Header

header 通常是HTML文档内容中的第一个元素,用来组织页面头部的内容,是对网站的介绍以及页面导航,一般性包括标识(Logo)标语(Slogan)菜单(Menu)

header 也可以被用作某篇文章(article)或某个区块(section)部分的头部内容。

footer 通常是HTML文档内容中的最后一个元素,包含网站一些次要的但是公共的(多个页面共享)信息,比如常用快捷链接、网站版权声明和备案信息等。

Main

main 元素包含当前页面的主体内容,网站各个页面可以共享header和footer这些通用元素,但main元素应该是彼此不同的。

Aside

aside 元素通常用来包含一些和当前页面内容有关的额外信息,比如博客文章页面的关联评论、推荐文章列表等,一般以左右边栏的形式呈现在页面两边。

Article

article 元素通常用于组织图文博客、论文和文章。

Section

section 元素的结构粒度要小一些,自身并不需要特别的语义,通常用来把一些相关的元素组合在一起。

下面是一个完整的示例(为了便于理解页面结构的布局,里面包含了CSS样式,可暂时忽略):

<!-- header begin -->
<header class="exp-header">
    <img class="logo" src="/uploads/151001/canon.png">
    <span>Techbrood is awesome :)</span>
    <div class="exp-menu"></div>
</header>
<!-- header end -->

<!-- main begin -->
<main class="exp-main">
    <!-- aside begin -->
    <aside class="comments">
        <h4>Latest comments</h4>
        <ul>
            <p>looks good</p>
            <p>i want more</p>
            <p>i have paid the awesome</p>
        </ul>
    </aside>
    <!-- aside end -->
    <article>
        <section class="intro">
            <h2>Introduction</h2>
            <p>
                Leading search engines on web creatives.
            </p>
            <ul>
                <li>HTML5</li>
                <li>CSS3</li>
                <li>WebGL</li>
                <li>SVG</li>
                <li>JavaScript/ES6</li>
            </ul>
            <h2>Description</h2>
            <p>
                We collect funny front-end works and tuturials from all over the world openning websites, and further we provide localization/indexing/tagging/deploying/online debugging services for these free resources.
                <a href="techbrood.com">techbrood.com</a>, we hope it help promoting the usage of new html5 techniques.
            </p>
            <ol>
                <li>techbrood.com</li>
                <li>wow.techbrood.com</li>
            </ol>
        </section>
        <section class="references">
            <h2>References</h2>
            <ol>
                <li><cite><a href="#">google.com</a></cite>, Google</li>
                <li><cite><a href="#">github.com</a></cite>, Github</li>
            </ol>
        </section>
    </article>
</main>
<!-- main end -->

<!-- footer begin -->
<footer class="exp-footer">
    <div>Copyright © 2015 TechBrood Co.</div>
    <div>沪ICP备14011478号</div>
</footer>
<!-- footer end -->
.exp-header,
.exp-footer {
    -webkit-transition-duration: 0.25s;
    transition-duration: 0.25s;
    -webkit-transition-delay: 0.25s;
    transition-delay: 0.25s;
    height: 9vh;
    z-index: 2;
    font-size: 120%;
    color: white;
    font-weight: 700;
}
.exp-header {
    background-color: #5d6373;
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;
    line-height: 9vh;
    padding-left: 1.5rem;
}
.exp-footer {
    width: 100%;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -webkit-flex-direction: row;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between;
}
.exp-menu {
    position: absolute;
    top: 0;
    right: 25px;
    height: 9vh;
    width: 9vh;
    background-color: #454b5b;
    box-shadow: 0 0 1rem rgba(0, 0, 0, 0.4);
}
.exp-menu:before {
    content: '';
    width: 1.3rem;
    height: 0.25vh;
    position: absolute;
    background-color: white;
    top: calc(9vh / 2 - 0.5rem);
    left: calc(9vh / 2 - 0.75rem);
    box-shadow: 0.25rem 0.5rem 0 white, 0 1rem 0 white;
}
.exp-footer {
    background-color: #252a37;
    position: fixed;
    width: 100%;
    bottom: 0;
    left: 0;
}
.exp-main {
    margin: 20px 0;
    width: 100%;
}
body {
    margin: 0;
    padding: 0;
}
.logo {
    position: relative;
    top: 8px;
}
aside {
    width: 25%;
    float: left;
    margin-left: 68.02721%;
    margin-right: -100%;
    padding-top: 20px;
    padding-bottom: 60px;
    margin-top: 40px;
    padding-left: 20px;
    color: #2f2a2a;
}
article {
    width: 60%;
    float: left;
    margin-left: 8.5034%;
    margin-right: -100%;
    padding-top: 20px;
    border-right: 1px dashed #666;
}
原文地址:https://www.cnblogs.com/hihtml5/p/6244112.html