Use Unicode characters for bullet points in CSS using ::marker

I was playing around with making some <ul>s on an HTML page recently, and typically when I want to replace the bullet points with an emoji or an SVG or something, I’ll write something like:

ul { list-style-type: none; }
ul li:before { content:…


This content originally appeared on DEV Community and was authored by Cassidy Williams

I was playing around with making some <ul>s on an HTML page recently, and typically when I want to replace the bullet points with an emoji or an SVG or something, I'll write something like:

ul { list-style-type: none; }
ul li:before { content:"\2713"; }

And this works, but for longer lines of text, you get some spacing issues. You can fix it by changing the padding around the list and messing with the positioning, but that's a lot of trial and error.

Enter, the ::marker psuedo-selector!

This is a really cool, relatively new option to solve our problem! It selects the marker box of a list item (so the bullet, or a number if you're using ol), and you can change the font properties, the color, and some other things around it!

Demo:

It's not fully compatible with Internet Explorer, and some other older versions of modern browsers. You can check the compatibility table here, and the documentation for it here!


This content originally appeared on DEV Community and was authored by Cassidy Williams


Print Share Comment Cite Upload Translate Updates
APA

Cassidy Williams | Sciencx (2022-04-07T23:20:12+00:00) Use Unicode characters for bullet points in CSS using ::marker. Retrieved from https://www.scien.cx/2022/04/07/use-unicode-characters-for-bullet-points-in-css-using-marker/

MLA
" » Use Unicode characters for bullet points in CSS using ::marker." Cassidy Williams | Sciencx - Thursday April 7, 2022, https://www.scien.cx/2022/04/07/use-unicode-characters-for-bullet-points-in-css-using-marker/
HARVARD
Cassidy Williams | Sciencx Thursday April 7, 2022 » Use Unicode characters for bullet points in CSS using ::marker., viewed ,<https://www.scien.cx/2022/04/07/use-unicode-characters-for-bullet-points-in-css-using-marker/>
VANCOUVER
Cassidy Williams | Sciencx - » Use Unicode characters for bullet points in CSS using ::marker. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/07/use-unicode-characters-for-bullet-points-in-css-using-marker/
CHICAGO
" » Use Unicode characters for bullet points in CSS using ::marker." Cassidy Williams | Sciencx - Accessed . https://www.scien.cx/2022/04/07/use-unicode-characters-for-bullet-points-in-css-using-marker/
IEEE
" » Use Unicode characters for bullet points in CSS using ::marker." Cassidy Williams | Sciencx [Online]. Available: https://www.scien.cx/2022/04/07/use-unicode-characters-for-bullet-points-in-css-using-marker/. [Accessed: ]
rf:citation
» Use Unicode characters for bullet points in CSS using ::marker | Cassidy Williams | Sciencx | https://www.scien.cx/2022/04/07/use-unicode-characters-for-bullet-points-in-css-using-marker/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.