Pick up the gameβs intuitive mechanics in minutes π·
Get everything you need to play in one box πΌ
Take control of a strangely familiar world πΈ
Turn eco-anxiety into a story with friends π―
With the request:
Is it possible to make the animal emoji be the list bullets?
Letβs find out.
Ye Olde Waye
The way we used to do this was by omitting the bullets entirely and then putting the content before. Traditionally this was done to get lists with cool angled-brackets like this:
We could do this.
Not bad! Notice that the 6th item has nothing. We could do some CSS math to make it cycle indefinitely; maybe that works for the client, maybe it doesnβt. Iβd like a bit more control over it though.
Letβs first re-work it to be more explicit.
I think in my actual implementation I used classes instead of data-bullet, so my CSS looked more like this:
Technically this is OK. Emoji are just UTF-8 characters that are rendered in a particular way by text-renderers that support the Emoji charset. Theyβre actually really neat, and there is far more technical stuff there than I had thought there would be.
This is still a pseudo-bullet though. Itβs visually shippable. But what if we wanted to get our semantic π?
The ::marker CSS pseudo-element selects the marker box of a list item, which typically contains a bullet or number. It works on any element or pseudo-element set to display: list-item, such as the <li> and <summary> elements.
Basically, we swap out ::before for ::marker.
One key, but subtle, difference is the change from this:
to this:
This is because weβre now returning the list to itβs normal behavior and just replacing the bullet being used.
The <ul> and <ol> elements have a top and bottom margin of 16px (1em) and a padding-left of 40px (2.5em).
We can do our padding and margins normally, as if we were using a standard disc (the default) marker.
Caveat: browser support
The ::marker pseudoelement is unfortunately still pretty new. So we want to play it safe by using the supports() CSS query.
For most users, this will look exactly the same. If it looks different, your browser might be one that doesnβt support the ::marker property and one of the earlier examples might look incorrect!