Skip to content
Discussion options

You must be logged in to vote

Yes, an <img> inside each <li> is valid semantic HTML. The ul and li elements still expose the list structure; the image is just decorative content inside each item. Give a decorative checkmark alt="" (and optionally aria-hidden="true") so a screen reader does not announce the same decoration for every item.

A simpler aligned version is:

<ul class="list-none space-y-2">
  <li class="flex items-start gap-2">
    <img src="/img/checkmark.png" alt="" class="mt-[0.35em] size-2 shrink-0" />
    <span>Item text</span>
  </li>
</ul>

The earlier pseudo-element version builds the same layout without an extra DOM element:

  • list-none removes the browser marker.
  • relative makes the <li> the positionin…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@RashiqAzhan
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by RashiqAzhan
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants