Rectangle 27 0

Marking up a search result list with HTML5 semantics?


Contexts in which this element may be used:

1) I think you should stick with the article element, as

2) If you're wondering if it's allowed to include article elements inside a li element, just feed it to the validator. As you can see, it is permitted to do so. Moreover, as the Working Draft says:

3) I wouldn't use nav elements for those categories, as those links are not part of the main navigation of the page:

4) Do not use the details and/or summary elements, as those are used as part of interactive elements and are not intended for plain documents.

@Jaffa: I don't agree: comments are usually a kind of waterfall of posts, sorted by date by nature (if I'm clear enough, my vocabulary is not that great at the moment); a search result list is a list in a specific order, with the best result (#1) at the top of the list. Also see the OP's requirement to order them by increasing number.

As a list of search results actually is a list, I think this is the appropriate element to use; however, as it seems to me that the order is important (I expect the best matching result to be on top of the list), I think that you should use an ordered list (ol) instead:

EDIT: Whoops, I just realized you already use an ol (due to my fatique, I thought you used an ul). I'll leave my update as is; after all, it might be useful to someone.

Is there any semantic benefit to the <ol> in this situation? Articles are scoped to their parent sectioning element so they're already grouped. Are they assumed to be ordered already, like <p>? If so, the only thing the <ol> offers is the 'start' attribute for paging.

It's unfortunate that <ol> doesn't allow some other tags to be children of it, like <article>. It could then be understood as an ordered list of articles. <li> in this case seems as arbitrary as the pervasive <div> tags HTML5 is supposed to move us away from.

Thank you for those clueful opinions! From that point of view, <article> is a good choice for the summary. You are right about <nav> as well. I know, however, that <li> may contain more or less any tags according to the doctype. My question is more like if it is a good way of using lists.

The ol element represents a list of items, where the items have been intentionally ordered, such that changing the order would change the meaning of the document. [source]

The ul element represents a list of items, where the order of the items is not important that is, where changing the order would not materially change the meaning of the document. [source]

UPDATE: Regarding if it's a good idea to use an (un)ordered list to present search results:

Using CSS you can simply hide the numbers.

You merely have a list of separate documents, so I think this is fully appropriate. The same is true for the front page of a blog, containing several posts with titles and outlines, each in a separate article element. Besides, if you intend to quote a few sentences of the articles (instead of providing summaries), you could even use blockquote elements, like in the example of a forum post showing the original posts a user is replying to.

[t]he article element represents a self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable [source]

only sections that consist of major navigation blocks are appropriate for the nav element. In particular, it is common for footers to have a short list of links to various pages of a site, such as the terms of service, the home page, and a copyright page. The footer element alone is sufficient for such cases, without a nav element. [source]

whatwg.org/specs/web-apps/current-work/multipage/ One of the examples is comments on a blog post, since the ordering of comments could be essential, we could assume that <article>s are already ordered.

Note
Rectangle 27 0

Marking up a search result list with HTML5 semantics?


Aiming for a 'perfect' HTML5 template is futile because the spec itself is far from perfect, with most of the prescribed use-cases for the new 'semantic' elements obscure at best. As long as your document is structured in a logical fashion, you won't have any problems with search engines (most of the new tags don't have the slightest impact). Indeed, following the HTML5 spec to the letter - for example, using <h1> tags within each new sectioning element - may make your site less accessible (to screen readers, for example). Don't strive for 'perfect' or close-to, because it doesn't exist - HTML5 is not thought-out well enough for that. Just concentrate on keeping your markup logical and uncluttered.

Note
Rectangle 27 0

Marking up a search result list with HTML5 semantics?


2 <abbr title="kilobyte">kB</code>
<dt>Categories</dt>
<dd>
 <ul>
  <li><a href="first-category.html">First category</a></li>
  <li><a href="second-category.html">Second category</a></li>
 </ul>
</dd>
<dt>Categories</dt>
<dd><a href="first-category.html">First category</a></dd>
<dd><a href="second-category.html">Second category</a></dd>
<ol start="1">

  <li id="1">
    <article>
     <h1><a href="url-to-the-page.html" rel="external">The Title of the Page</a></h1>
     <p>A short summary of the page</p>
     <footer>
       <dl>
         <dt>Categories</dt>
         <dd><a href="first-category.html">First category</a></dd>
         <dd><a href="second-category.html">Second category</a></dd>
         <dt>File size</dt>
         <dd>2 <abbr title="kilobyte">kB</code></dd>
         <dt>Published</dt>
         <dd><time datetime="2010-07-15T13:15:05-02:00">Today</time></dd>
        </dl>
      </footer>
    </article>
  </li>

  <li id="2">
    <article>
     
    </article>
  </li>

</ol>
  • give hreflang attribute to the link if the linked result has a different language than the search engine
  • give lang attribute to the link description and the summary if it is in a different language than the search engine
  • summary: use blockquote (with cite attribute) instead of p, if the search engine does not create a summary itself but uses the meta-description or a snippet from the page.
  • title/link description: use q (with cite attribute) if the link description is exactly the title from the linked webpage

Each li should get id atribute, so that you can link to it. The value should be the rank/position.

I'd markup it up this way (without using any RDFa/microdata vocabularies or microformats; so only using what the plain HTML5 spec gives):

If the search engine uses pagination, you should give the start attribute to the ol, so that each li reflects the correct ranking position.

Instead, you should list each category in its own dd and remove the ul:

It is not needed if it contains only the heading (h1).

It's not in the spec anymore.

One could think that the id should be given to the article instead, but I think this would be wrong: the rank/order could change by time. You are not referring to a specific result but to a result position.

The category links are not navigation in scope of the article. So remove the nav.

The link to each search result is an external link (leading to a different website), so it should get the rel value external.

The unit in "2 kB" should be marked-up with abbr:

Note
Rectangle 27 0

Marking up a search result list with HTML5 semantics?


2 <abbr title="kilobyte">kB</code>
<dt>Categories</dt>
<dd>
 <ul>
  <li><a href="first-category.html">First category</a></li>
  <li><a href="second-category.html">Second category</a></li>
 </ul>
</dd>
<dt>Categories</dt>
<dd><a href="first-category.html">First category</a></dd>
<dd><a href="second-category.html">Second category</a></dd>
<ol start="1">

  <li id="1">
    <article>
     <h1><a href="url-to-the-page.html" rel="external">The Title of the Page</a></h1>
     <p>A short summary of the page</p>
     <footer>
       <dl>
         <dt>Categories</dt>
         <dd><a href="first-category.html">First category</a></dd>
         <dd><a href="second-category.html">Second category</a></dd>
         <dt>File size</dt>
         <dd>2 <abbr title="kilobyte">kB</code></dd>
         <dt>Published</dt>
         <dd><time datetime="2010-07-15T13:15:05-02:00">Today</time></dd>
        </dl>
      </footer>
    </article>
  </li>

  <li id="2">
    <article>
     
    </article>
  </li>

</ol>
  • give hreflang attribute to the link if the linked result has a different language than the search engine
  • give lang attribute to the link description and the summary if it is in a different language than the search engine
  • summary: use blockquote (with cite attribute) instead of p, if the search engine does not create a summary itself but uses the meta-description or a snippet from the page.
  • title/link description: use q (with cite attribute) if the link description is exactly the title from the linked webpage

Each li should get id atribute, so that you can link to it. The value should be the rank/position.

I'd markup it up this way (without using any RDFa/microdata vocabularies or microformats; so only using what the plain HTML5 spec gives):

If the search engine uses pagination, you should give the start attribute to the ol, so that each li reflects the correct ranking position.

Instead, you should list each category in its own dd and remove the ul:

It is not needed if it contains only the heading (h1).

It's not in the spec anymore.

One could think that the id should be given to the article instead, but I think this would be wrong: the rank/order could change by time. You are not referring to a specific result but to a result position.

The category links are not navigation in scope of the article. So remove the nav.

The link to each search result is an external link (leading to a different website), so it should get the rel value external.

The unit in "2 kB" should be marked-up with abbr:

Note