CSS Emoji list style

I'm a full-stack developer from South Africa πΏπ¦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa πΏπ¦. I love writing about JavaScript, HTML and CSS.
Hey Dinys,
You could technically do this yes, but keep in mind the content will then also contain these icons.
The emojis are of course an example of what you could add as custom list items.
In this case, the result would be exactly the same having them directly in HTML, but considering SEO and Styling options this gives us more options to play with.
Customisation FTW π
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

As you may have seen throughout my articles, I'm a big fan of Emojis.
Today we'll be looking at getting emoji as our list icons. I will be using the stable method for this article. Tomorrow we will explore a newer method of doing just this.
The end result will be us transforming the left list into this right one.
Try it out using this Codepen.
<div>
<h1>The big five!</h1>
<ul>
<li>Lion</li>
<li>Leopard</li>
<li>Rhino</li>
<li>Elephant</li>
<li>Buffalo</li>
</ul>
</div>
<div>
<h1>The big five!</h1>
<ul class="styled">
<li>Lion</li>
<li>Leopard</li>
<li>Rhino</li>
<li>Elephant</li>
<li>Buffalo</li>
</ul>
</div>
As you can see twice the same list, only the second one has a class styled.
Now we want to make the difference between a boring list and a cool emoji list!.
To get the emoji list-style we first will remove the actual styling from the list.
The list-style: none will remove the default bullets and then we set the padding and margin to be zero.
.styled {
list-style: none;
padding: 0;
margin: 0;
}
The next step is to give the list items some space.
This will give us a indent on the left where we can use the before selector to showcase our emoji.
.styled li {
padding-left: 1rem;
text-indent: -0.75rem;
}
And the third and final step to showcase the emoji.
We are using the before selector to place the content of the animal.
.styled li::before {
content: "π¦ ";
}
We can now use the nth-child selector to do the other animals.
.styled li:nth-child(2)::before {
content: "π ";
}
.styled li:nth-child(3)::before {
content: "π¦ ";
}
.styled li:nth-child(4)::before {
content: "π ";
}
.styled li:nth-child(5)::before {
content: "π ";
}
That's is a way cooler list!
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter