htmlsemanticsarticle

The article tag and the img


I understand that the article tag is "an independent item section of content" www.w3.org/wiki/HTML/Elements/article

I have a page only with a blog post. That blog has an img and a caption on top of the text (it is an img that illustrates what I tell in the text of the blog). Should the img and caption be inside or outside the article tag?

The img:

<img src="1.png">
<div>Caption of the image</div>

The blog post simplified:

<article>
<h1>Title of the post</h1>
<div>Last Updated: 2016-01-07</div>
<div>       
    <p>This is the body of the post</p>
</div>
<p>Author of the post</p>
</article>

Solution

  • You may want to check both figure and figcaption tags.

    example from the docs:

    <figure>
      <img src="https://developer.cdn.mozilla.net/media/img/mdn-logo-sm.png" alt="An awesome picture">  
      <figcaption>Fig1. MDN Logo</figcaption>
    </figure>
    

    And if the figure is related to the article, then I'd put it inside the article tag.