Repository navigation
How to style List Style Image items #20488
|
How do I style I tried |
Replies: 3 comments 1 reply
|
There is no <ul class="list-none">
<li class="relative pl-6 before:absolute before:left-0 before:top-[0.35em] before:size-2 before:bg-[url('/img/checkmark.png')] before:bg-contain before:bg-no-repeat before:content-['']">
Item
</li>
</ul>For a dynamic/accessible icon, an actual |
|
Yes, an 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:
The key distinction is that |
|
In the CSS specification, the To control the size and position of custom bullet images with Tailwind CSS, there are two standard patterns: Pattern 1: Using
|
Yes, an
<img>inside each<li>is valid semantic HTML. Theulandlielements still expose the list structure; the image is just decorative content inside each item. Give a decorative checkmarkalt=""(and optionallyaria-hidden="true") so a screen reader does not announce the same decoration for every item.A simpler aligned version is:
The earlier pseudo-element version builds the same layout without an extra DOM element:
list-noneremoves the browser marker.relativemakes the<li>the positionin…