Use emoji as list bullet points using CSS list-style

featured Image

In this article, we will see how to style list bullet points with emoji in HTML.

In HTML the available list styles are very limited and sometimes it may make the list look boring.

So, how to make our old HTML bullet points a little bit more interesting? The answer is adding Emojis.

So, here in this post, we will see how to replace the bullet points with Emojis using CSS.

We can add emoji using to list-style using:

  1. Using :before pseudo-element
  2. using @counter-style CSS rule

Using :before pseudo-element

We have to use the :before element to replace the disc bullet point style with an emoji.

First we have to set the parent, <ul> or <ol> list-style property to none, list-style:none and then setting the margin and padding to 0px.

Next, to add the emoji icons before the list items we will use the content property on :before pseudo-element on the <li> tag.

Example:

ul{
    margin:0px;
    padding:0px
}

ul li{
    list-style:none;
}

ul li:before{
    content: '👉'
}

Result:

add emoji to bullet points

You can also select different emojis for different list items using the nth-child selector like this

ul li:before{
  content: '👉'
}
li:nth-child(2)::before {
  content: '🔎 ';
}
li:nth-child(3)::before {
  content: '🗯 ';
}

Result:

bullet style emoji css

Using @counter-style to create emoji list bullet point

The @counter-style CSS at-rule allows you to create/define a custom counter-style that is not a part of a pre-defined set of styles.

It takes in three properties: 1. system, 2. symbols, and 3. suffix

system: It lets you specify the algorithm to convert the integer value into a string representation. It accepts the following values:

cyclic | numeric | alphabetic | symbolic | additive | [fixed <integer>?] | [ extends <counter-style-name> ]

symbols: These are the Unicode code points to represent the emojis. You can add multiple space-separated sets of symbols. Get the List of Unicode codes of Emoji.

suffix: Any character you want to appear after the counter and before the text. We will keep it blank space (” “) here.

Example:

@counter-style emoji-bullets {
  system: cyclic;
  symbols: "1F680""1F436""1F60E";
  suffix: " ";
}

/* Add this class to the ul or ol element */
ul li {
  list-style-type: emoji-bullets;
}

Result:

Styling list bullets with emoji

Read more about @counter-style here: @counter-style | MDN – Mozilla


Related Topics:

How to remove bullets from an unordered list using CSS

How to create a horizontal list using HTML and CSS

Make a collapsible list in html without JavaScript

Related Posts

featured Image

Disable scrolling Behavior on a body with element on position fixed in mobile

Here in this article, we will learn on how to disable the scroll behavior of the body whenever we scroll over an element whose position is fixed in our mobile…

Read more
featured Image

How to Remove Underline from Links in Bootstrap.

In this article, we will learn how to remove the underline from anchor tags in Bootstrap. Just like any other HTML element, links can also be styled using CSS. We…

Read more
featured Image

How to disable the resizable property of a textarea

In this article, we will see quick ways to disable the resizable property of a textarea using CSS. In CSS, we can disable it using the resize property. Set resize…

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *