Write the HTML markup for several of (profile picture + message heading + message) I was asked to write the HTML markup and CSS like the following:




User's profile picture on the left
his message heading
his message content


I was so concerned with how to correctly make it displayed (with JavaScript data and render it into HTML, and the HTML would result as:

&lt;div class="comment-section"&gt;
  &lt;div class="comment"&gt;
    &lt;img src="http://i.imgur.com/IKaRi8s.jpg"&gt;&lt;div class="comment-text"&gt;&lt;h4&gt;heading&lt;/h4&gt;&lt;div&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.&lt;/div&gt;&lt;/div&gt;
  &lt;/div&gt;

  &lt;div class="comment"&gt;
    &lt;img src="http://i.imgur.com/972Ww14.png"&gt;&lt;div class="comment-text"&gt;&lt;h4&gt;heading&lt;/h4&gt;&lt;div&gt;content...&lt;/div&gt;&lt;/div&gt;
  &lt;/div&gt;

  &lt;div class="comment"&gt;
    &lt;img src="http://i.imgur.com/kS6KI6K.jpg"&gt;&lt;div class="comment-text"&gt;&lt;h4&gt;heading&lt;/h4&gt;&lt;div&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


with CSS

.comment-section { width: 400px; font: 13px Arial, sans-serif; }
.comment-section .comment { margin: 10px 0; }
.comment-section img, .comment-section .comment-text { display: inline-block; }
.comment-section img { width: 50px; height: 50px; margin-right: 5px; }
.comment-section .comment-text { vertical-align: top; width: 340px; }
.comment-section h4 { margin: 0 0 2px; }


Example at: https://jsfiddle.net/zayquc9q/2/

Should I actually have used &lt;li&gt; and &lt;p&gt;:

&lt;ul class="comment-section"&gt;
  &lt;li&gt;
    &lt;img src ...&gt;&lt;div class="comment-text"&gt;&lt;h3&gt;heading&lt;/h3&gt;&lt;p&gt;content...&lt;/p&gt;&lt;/div&gt;
  &lt;/li&gt;

  &lt;!-- ... other li like above --&gt;

&lt;/ul&gt;


Or &lt;section&gt; and &lt;article&gt; instead?

&lt;section class="comment-section"&gt;
  &lt;article&gt;
    &lt;img src ...&gt;&lt;div class="comment-text"&gt;&lt;h3&gt;heading&lt;/h3&gt;&lt;p&gt;content...&lt;/p&gt;&lt;/div&gt;
  &lt;/article&gt;

  &lt;!-- ... other article like above --&gt;

&lt;/section&gt;


So although what I did looked pretty good in the real webpage, I don't know whether it was that it wasn't semantic markup that they disqualified me (for a JavaScript / React / Redux position), after this phone interview.
If it's all about semantic then let's see what HTML5 specs say (emphasis is mine):


  The article element represents a component of a page that consists of a self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.


In this case it seems that &lt;article&gt; is an appropriate choice for your comments. Is it &lt;section&gt; an appropriate container? I don't think it is, specs says:


  The section element represents a generic document or application section…The section element is not a generic container element. When an element is needed only for styling purposes or as a convenience for scripting, authors are encouraged to use the div element instead. A general rule is that the section element is appropriate only if the element’s contents would be listed explicitly in the document’s outline.


I agree that interpretation can be little bit subjective here but I'd take it literally: you do not have a specific header for this section. In your case if &lt;section&gt; is not to group a section of your document (for example an outer &lt;article&gt; with its list of comments) then I'd use the good old &lt;div&gt;:

&lt;div class="comment-section"&gt;
  &lt;article&gt;
  &lt;/article&gt;
&lt;/div&gt;


If, however, comments are just a part (section) of your main document which you may want to see in document outline and not simply a styling container (remember that it's important for screen-readers and all the others assistive tools) then don't refrain and use &lt;section&gt;.



Now let's talk about article content. You're using &lt;h4&gt; for styling purposes. I don't see whole page outline then I can't comment on this but keep in mind that heading elements should be used to denote an hypothetical structure, not for their styling. Imagine to replace your &lt;h4&gt;Title&lt;/h4&gt; with &lt;div class="header"&gt;Title&lt;/div&gt; where div.header is appropriately styled. Does the meaning of your document is lost? If answer is no then you're using heading elements because of styling and you shouldn't.

HTML5 introduced a new element  which may be appropriate in your case:

&lt;div class="comment-section"&gt;
  &lt;article&gt;
      &lt;header&gt;...&lt;/header&gt;
  &lt;/article&gt;
&lt;/div&gt;


Note that even if you really want to keep  because of its meaning in document outline I'd wrap it inside an &lt;header&gt; section.

&lt;div class="comment-section"&gt;
  &lt;article&gt;
      &lt;header&gt;
          &lt;h4&gt;Title&lt;/h4&gt;
      &lt;/header&gt;
  &lt;/article&gt;
&lt;/div&gt;


What is it useful for? For example if tomorrow you will add subtitle to hold the date and the author of the comment...

Now let's think about &lt;img&gt;. First of all it has to have an alt attribute but I'd also consider to move it into its own &lt;aside&gt; element. It may help screen readers to keep "focus" on the content. About this...do not forget to include all the proper aria- attributes!