html - 应该使用什么 html5 标签来过滤搜索结果

标签 html tags semantic-markup

如果我有一个页面区域,其中包含用于过滤搜索结果的不同选项(带有链接、复选框、选择等的无序列表)。应该使用什么 html5 标记来包装该过滤器? “section”标签、“nav”标签或其他标签?

<div id="search-filters"> <!-- This should be a div, a nav, a section? -->
    <h3>Price</h3>
    <ul>
        <li>less than 100</li>
        <li>100 - 200</li>
        <li>more than 200</li>
    </ul>

    <h3>Brand</h3>
    <ul>
        <li>Brand A</li>
        <li>Brand B</li>
        <li>Brand C</li>
    </ul>

    ...
</div>
<section id="search_results">
    ...
</section>

最佳答案

您可以使用 header element :

The header element represents a group of introductory or navigational aids.

请注意,header 需要搜索结果的分段元素(在您的情况下为 section):

<section id="search_results">

  <h1>Search results</h1>

  <header id="search-filters">
    <!-- your filters -->
  </header>

  <article>
    <!-- search result 1 -->
  </article>

  <article>
    <!-- search result 2 -->
  </article>

</section>

如果愿意,您也可以在 header 中包含 h1。如果您随后需要过滤器的样式 Hook ,则可以使用包装器 div

如果您的过滤器相当复杂,例如如果您提供许多过滤器,可能带有副标题,您可以在 header 中使用 section 元素:

<section id="search_results">

  <h1>Search results</h1>

  <header id="search-filters">
    <section>
      <h2>Filter the results</h2>
      <!-- your filters -->
    </section>
  </header>

  <article>
    <!-- search result 1 -->
  </article>

  <article>
    <!-- search result 2 -->
  </article>

</section>

关于html - 应该使用什么 html5 标签来过滤搜索结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17240667/

相关文章:

javascript - 有没有可能一个元素只监听点击事件而忽略鼠标移动等事件?

python - 如何使用 python 将多个列表组合成多个字典?

css - 您可以将任意元素包装在 "figure"中以指示它是 HTML-as-image 吗?

html - 使用 W3C 有效表示元素有哪些实际缺点,哪些未被列为已弃用?

html - 将子内容定位在父容器之外

javascript - Bootstrap 2 关于 html select 选项的工具提示

javascript - 为动态 div block 添加链接和图像

php - Mpdf 删除页脚并使用它的内容空间

html - 使用纯 HTML5/CSS3 创建标签云

html - 如何为图像而不是表格使用 html 5 <caption> 标签