我应该使用 <section><aside> 内的标签? [英] Shall I use <section> tags inside <aside>?

查看:20
本文介绍了我应该使用 <section><aside> 内的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有这样的标记:

<aside>
    <div class="widget">
        <h2>Latest news</h2>
        <ul>...</ul>
        <a>more news</a>
    </div>
    <div class="widget">
        <h2>Choose site theme</h2>
        <input type="select" />
    </div>
    <div class="widget">
        <h2>Newsletter subscription</h2>
        <form>...</form>
    </div>
    <div class="widget">
        <h2>Related articles</h2>
        <ul>...</ul>
    </div>
</aside>

这里哪个标签更合适:<div>还是<section>?
部分是否应该只在 <article> 标记内使用,而不能在 <aside> 内使用?

Which tag is more appropriate here: <div> or <section>?
Is section supposed to be used only inside <article> tag and never inside <aside>?

推荐答案

HTML 5 规范不禁止您在 aside 元素内使用 section 元素.aside 元素允许在里面有流内容,并且包括 section 元素.

The HTML 5 spec does not prohibit you from using the section element inside of an aside element. The aside element is allowed to have flow content inside, and that includes the section element.

然而,即使 div 元素现在在 HTML5 中被认为是最后的手段"的分段元素,在这种情况下使用 section 与元素的意图.从我们看到的规范来看:

However, even though the div element is now, in HTML5, supposed to be the sectioning element of "last resort", using section in this context goes against the intent of the element. From the spec we see:

注意:section 元素不是通用容器元素.当一个元素仅用于样式目的或为了方便编写脚本时,鼓励作者使用 div 元素.一般规则是,仅当元素的内容将在文档的大纲中明确列出时,section 元素才是合适的.

Note: The section element is not a generic container element. When an element is needed only for styling purposes or as a convenience for scripting, authors are encouraged to use the div element instead. A general rule is that the section element is appropriate only if the element's contents would be listed explicitly in the document's outline.

现在,旁白的小部分"绝对不属于整个文档的大纲,所以对您的问题的简短回答是使用 div.或者,因为你的 side 看起来里面有四个项目",你可以考虑一个带有四个 liul,然后使用规则 aside ul li 设置样式.

Now, little "sections" of an aside are definitely not something that belong in the outline of the entire document, so the short answer to your question is to use div. Alternatively, because your aside looks like it has four "items" inside, you might consider a ul with four lis and then style with the rule aside ul li.

这篇关于我应该使用 &lt;section&gt;&lt;aside&gt; 内的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆