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:
<div class="comment-section">
<div class="comment">
<img src="http://i.imgur.com/IKaRi8s.jpg"><div class="comment-text"><h4>heading</h4><div>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.</div></div>
</div>
<div class="comment">
<img src="http://i.imgur.com/972Ww14.png"><div class="comment-text"><h4>heading</h4><div>content...</div></div>
</div>
<div class="comment">
<img src="http://i.imgur.com/kS6KI6K.jpg"><div class="comment-text"><h4>heading</h4><div>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.</div></div>
</div>
</div>
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 <li>
and <p>
:
<ul class="comment-section">
<li>
<img src ...><div class="comment-text"><h3>heading</h3><p>content...</p></div>
</li>
<!-- ... other li like above -->
</ul>
Or <section>
and <article>
instead?
<section class="comment-section">
<article>
<img src ...><div class="comment-text"><h3>heading</h3><p>content...</p></div>
</article>
<!-- ... other article like above -->
</section>
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.
div
vsul
vssection
andarticle
, and leave the minor details out. But if you wanted it, here there are \$\endgroup\$ul
andli
. I think you can say that it is a "list" of (profilePicture + comments). One mind-boggling markup I have seen were the star-rating system. It was a list of 5 items: 1 to 5 stars which are radio buttons, and then it is styled to be the horizontal star-rating bar such as the one you see on Amazon.com or Apple.com \$\endgroup\$