【问题标题】:What is the appropriate semantic HTML tag for a short blurb underneath a heading?对于标题下方的简短宣传,合适的语义 HTML 标记是什么?
【发布时间】:2021-05-10 18:38:18
【问题描述】:

对于标题下方的简短宣传,最好的语义 HTML 标记是什么?我确定它有一个名字,因为很多网站都有这个名字,但我似乎找不到它或合适的标签。

<h1>Page Title</h1>

<h2>Section Title</h2>
<div>Short blurb about this section</div>
<div>Section content</div>

【问题讨论】:

    标签: html accessibility semantics wai-aria


    【解决方案1】:

    您可以使用小标签代替 p 标签,就像我在下面所做的那样。这个页面应该可以帮助https://www.w3schools.com/html/html_formatting.asp

    <header>
       <h1>HTML 5.1 Nightly</h1>
       <small>A vocabulary and associated APIs for HTML and XHTML</small>
       <small>Editor’s Draft 9 May 2013</small>
    </header>

    【讨论】:

    • 这也与我刚刚发现的非常相似。似乎只需要将其全部包装在 &lt;header&gt; 标签中即可。
    • 是的,这也可以。很高兴你弄明白了!
    【解决方案2】:

    发布后不久,我找到了问题的答案。根据W3,我应该将标题和简介(他们称之为副标题)包装在&lt;header&gt; 标签中:

    示例 4:在以下示例中,新闻文章的标题和标语使用 &lt;header&gt; 元素进行分组。标题使用h2 元素标记,标语在p 元素中。代码示例下方提供了标题和标语的示例 CSS 样式呈现。

    <header>
      <h2>3D films set for popularity slide </h2>
      <p>First drop in 3D box office projected for this year despite hotly tipped summer blockbusters,
      according to Fitch Ratings report</p>
    </header>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-26
      • 1970-01-01
      • 1970-01-01
      • 2013-08-03
      • 2014-09-12
      • 1970-01-01
      • 2015-09-08
      相关资源
      最近更新 更多