While this question may be dated, the discussion it opens up is still intriguing.
The use of a div
HTML element is possible, but from a semantic standpoint, it may not be the most efficient choice. It's important to remember that div
is considered the most generic HTML element, offering little insight into the content it contains beyond separating it visually.
An alternative method would involve utilizing more descriptive HTML 5 elements and customizing their styling to resemble a chat bubble.
Take for instance this modified example sourced from this informative article
<ul class="chat">
<li class="message">
<figure class="sender">
<img src="https://example.org/avatar.png" alt="" class="avatar" />
<figcaption>Example sender name</figcaption>
</figure>
<blockquote>
<p>Text message</p>
</blockquote>
<li>
<!-- additional chat messages here ... -->
</ul>