【问题标题】:Naming a HTML5 <section> with inline <span> rather than block level element使用内联 <span> 而不是块级元素命名 HTML5 <section>
【发布时间】:2014-11-28 17:04:15
【问题描述】:

据我了解,良好的 HTML5 做法是使用 h2-h6 标签命名所有部分:

<section id='chapter_one' class='chapter'>
  <h3>Chapter One</h3>
  <p>My site has lots of content.</p>
</section>

没有元素,w3c 验证器给出“节缺少标题。考虑使用 h2-h6 元素为所有节添加标识标题”。很好,但是有没有办法为节标签使用内联元素而不是块元素?

<section id='chapter_one' class='chapter'>
  <p>Welcome to <span>Chapter One</span> of my fine content rich site.</p>
</section>

参考:http://www.smashingmagazine.com/2013/01/18/the-importance-of-sections/w3c html validation error - Section lacks heading. Consider using h2-h6 elements to add identifying headings to all sectionsIs it necessary to have a heading of <section> in HTML5

【问题讨论】:

    标签: html validation w3c-validation


    【解决方案1】:

    没有。

    正如 HTML5 规范在 Headings and sections 中定义的那样:

    分节内容元素中标题内容的第一个元素表示该节的标题。

    heading content 类别包含:

    h1h2h3h4h5h6

    【讨论】:

    • aria-labelledby="chapter_{{id}}" 怎么样
    • @Bryce:WAI-ARIA 不会影响文档大纲。 (它可以帮助辅助技术,但不一定会被您的 HTML 的其他消费者使用。)
    猜你喜欢
    • 2011-08-29
    • 2010-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-23
    • 2020-02-21
    相关资源
    最近更新 更多