Semantic HTML of an articles list

felixjet picture felixjet · Oct 11, 2013 · Viewed 18.4k times · Source

In a typical index of articles (like a blog without excerpt) like this image:

example

those items should be a list (<ul><li>) or just divs?

And also, they should be figure/figcaption? Because would make some sense, but also... picture is part of an artcile not the main content, so maybe title/description is not the caption of the image, but the caption of the article.

what do you think?

EDIT: a live example - https://news.google.com/?hl=en

Answer

unor picture unor · Oct 11, 2013

I’d use an article for each snippet (i.e. a news teaser).

Each article contains an h1 element for the heading, an img element for the image, and p element(s) for the text.

As you probably want to link to a full version, you could enclose all elements in one a element (which is allowed in HTML5), or the heading etc. only.

So it could look like:

<article>
  <h1><a href="" title=""><!-- news title --></a></h1>
  <img src="" alt="" />
  <p><!-- news description --></p>
</article>

Only use figure if this image itself should have a separate caption. The news description (here contained in p) usually isn’t the caption for that image.

You may change the order of the article children. Thanks to the way sectioning elements work, the heading doesn’t have to be the first element.

You may use an ul, but it’s not necessary. ol, however, should only be used if the order is really meaningful for understanding the content (i.e. a different order would change the meaning of the document). Typical example: if the items are ranked by relevance (e.g. most relevant teaser at the top), you should use ol.


Regarding your question if the teaser should be an article:

Don’t confuse article (HTML5 element) with the term "article" (English language). article has a separate definition that doesn’t necessarily have something to do with the understanding of the term "article".

The teaser should also be an article – the teaser article and the fulltext article are different articles, although they refer to the same entity.