【问题标题】:Should I use a HTML5 tag for my search?我应该使用 HTML5 标签进行搜索吗?
【发布时间】:2012-03-20 08:57:18
【问题描述】:

我是否应该在新网站上使用 HTML5 特定标签进行搜索,以便保持语义正确? 我的网站结构是这样的

--------------------
      Header
--------------------
search   |   nav
--------------------
      article
--------------------
       footer
--------------------

这主要是因为搜索在此页面上起着重要作用。

【问题讨论】:

    标签: html search semantics


    【解决方案1】:

    你可以使用:

    <input type="search">
    

    搜索是一种浏览网站的方式,因此您只需将其添加到 &lt;nav&gt; 元素即可。

    在这种情况下,&lt;nav&gt; 元素可以是&lt;header&gt;just like the last example in the spec 的子元素。

    <header>
      <h1>Site title</h1>
      <input type="search" placeholder="Search…">
      <nav>
        …
      </nav>
    </header>
    <article>
      <h1>Page title</h1>
    </article>
    <footer>
      …
    </footer>
    

    【讨论】:

    • 我读到过这种方法,但我不确定
    【解决方案2】:

    你的结构应该是这样的(如果你遵循 html5):

    <header>this is header</header>
    
    <section>
        <section>
            <form>
              <input type="search">
            </form>
        </section>
        <nav>
            this is navigation
        </nav>
    </section>
    
    <main>
        <article>this content article</article>
        <aside>this sidebar</aside>
    </main>
    
    
    <footer>this is footer</footer>
    

    【讨论】:

      猜你喜欢
      • 2011-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-30
      • 2015-05-25
      • 1970-01-01
      • 2021-08-25
      • 1970-01-01
      相关资源
      最近更新 更多