6

我正在尝试制作语义 HTML5 代码,但不确定它是否正确。Visualy 我有一篇文章/帖子分为 3 列:

图片(200 像素)| H1+ 总结 + 更多链接(350px) | 带有 2 个标题 H2 的附加部分 (150 像素)

在 CSS 中,我会浮动:左图.post-summary、.post-aside

这是Ver.1:

<article>
        <figure>
        <a href="#"><img src="images/temp/entry_01.jpg" alt=""></a>
        <figcaption>Title for Case Study</figcaption>
        </figure>

        <div class="post-summary">          
            <section>
                <h1>MAIN Article Title</h1>
                <p>Lorem ipsum...</p>
                <a href="#">read more</a>
            </section>              
        </div>

        <div class="post-aside">
            <section>
                <h2>The Charges:</h2>
                <p>Lorem ipsum...</p>
            </section>

            <section>
                <h2>The Verdict:</h2>
                <p>Lorem ipsum...</p>
            </section>
        </div>
</article>

版本。2

<article>
        <figure>
        <a href="#"><img src="images/temp/entry_01.jpg" alt=""></a>
        <figcaption>Title for Case Study</figcaption>
        </figure>

        <section class="post-summary">
            <h1>MAIN Article Title</h1>
            <p>Lorem ipsum...</p>
            <a href="#">read more</a>
        </section>                          

        <section class="post-aside">
            <h2>The Charges:</h2>
            <p>Lorem ipsum text ...</p>

            <h2>The Verdict:</h2>
            <p>Lorem ipsum text...</p>
        </section>

</article>  

哪一个是对的?

4

2 回答 2

6

取决于你想要什么。。

div — 我们都知道和喜爱的“通用流容器”。它是一个没有额外语义含义的块级元素。

section — “通用文档或应用程序部分”。一个部分通常有一个标题(标题),也可能有一个页脚。它是一大块相关内容,例如一篇长文章的一个小节,页面的主要部分(例如主页上的新闻部分),或者 webapp 选项卡式界面中的一个页面。

http://boblet.tumblr.com/post/130610820/html5-structure1 文章链接

我会以这种方式使用它(你的 v2):

<div> <!-- Main article div -->
    <article> <!-- First article -->
        <section><!-- Header, about the author... --></section> 
        <section><!-- related info .. --></section> 
        <section><!-- conclusion --></section> 
    </article>

    <article>
        <section></section>
        <section></section>
        <section></section>
    </article>
</div>
于 2012-05-10T09:40:53.553 回答
-20

这是不对的......他们两个,答案也是......不要使用 DIV !使用部分代替!

于 2012-05-10T13:41:26.927 回答