CSS / 5 MIN READ
Change Bullet Color
Learn how to change the color of list bullets in CSS.
From the original Fervor library. Examples may use older package versions.
π¨ How to Change the Color of Bullets in an <li> Using CSS
By default, the bullets in a <ul> (unordered list) take on the text color of the list items (<li>). But what if you want the bullets to have a different color than the text? CSS has got you covered! Letβs go step by step.
π οΈ Method 1: Using ::marker (The Best & Easiest Way π―)
CSS introduced the ::marker pseudo-element, which specifically targets the bullet (or number in an ordered list).
β Example:
ul li::marker {
color: red; /* Change bullet color */
font-size: 1.5em; /* Make the bullet bigger */
}
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ul>
πΉ What happens? The bullets will turn red while the text remains its default color.
π Bonus: You can also add custom styles to bullets, like changing their size or using Unicode characters!
ul li::marker {
color: blue;
content: "π₯ "; /* Custom bullet */
}
π οΈ Method 2: Using list-style-image (For Fancy Custom Bullets πΌοΈ)
If you want to replace the bullet with an image, you can use list-style-image.
β Example:
ul {
list-style-image: url('bullet.png'); /* Replace with your image */
}
π Downside: This method can be a bit outdated and doesnβt allow color changes directlyβjust image replacements.
π οΈ Method 3: Using list-style-type + ::before (More Customization π¨)
For even more control, use ::before with content to manually create bullets.
β Example:
ul {
list-style-type: none; /* Remove default bullets */
}
ul li::before {
content: "β’"; /* Custom bullet */
color: green; /* Change bullet color */
font-size: 1.2em; /* Adjust size */
margin-right: 8px;
}
<ul>
<li>Dog</li>
<li>Cat</li>
<li>Rabbit</li>
</ul>
πΉ Why use this? It gives full styling control over the bulletβs appearance, including font, size, spacing, and color.
π Which Method Should You Use?
| Method | Best For | Notes |
|---|---|---|
::marker |
Simple bullet color change | Best for modern browsers β |
list-style-image |
Using custom images as bullets | Might not work well in all cases β οΈ |
::before |
Full control over bullet styles | Works even in older browsers π‘ |
π― Conclusion
If you just want to change the bullet color, go with ::marker.
If you want full customization, ::before is your best bet.
π Fun & Creative Things to Do with List Bullets in CSS!
Now that we know how to style bullets, letβs get creative! Here are some cool and fun ways to customize bullets using CSS.
1οΈβ£ Emoji Bullets for a Fun Touch π
Who said bullets have to be boring dots? Replace them with emojis!
π¨ CSS:
ul {
list-style-type: none; /* Remove default bullets */
}
ul li::before {
content: "β"; /* Star emoji as bullet */
color: gold;
font-size: 1.2em;
margin-right: 8px;
}
π Output:
β Item 1
β Item 2
β Item 3
πΉ Try different emojis:
- β
"β "for checklists - π₯
"π₯"for a hot list - π₯
"π₯"for ranking lists
2οΈβ£ Gradient Bullets for a Fancy Look π
Want bullets that change colors? Try a gradient effect!
π¨ CSS:
ul li::marker {
color: linear-gradient(to right, red, blue); /* Won't work directly */
}
π Why? ::marker doesnβt support gradients, but you can fake it:
ul {
list-style-type: none;
}
ul li::before {
content: "⬀";
background: linear-gradient(to right, red, blue);
-webkit-background-clip: text;
color: transparent;
font-size: 1.5em;
margin-right: 8px;
}
π¨ Result: A smooth gradient effect on bullets!
3οΈβ£ Make Bullets Rotate on Hover π
Make your bullets spin when hovered over for a cool effect!
π¨ CSS:
ul {
list-style-type: none;
}
ul li::before {
content: "π΅"; /* Use any symbol */
display: inline-block;
margin-right: 8px;
transition: transform 0.3s ease-in-out;
}
ul li:hover::before {
transform: rotate(360deg);
}
π Result: Hover over an item, and the bullet spins!
4οΈβ£ Animating Bullets with a Bouncy Effect πΎ
Make bullets bounce when you hover!
π¨ CSS:
ul {
list-style-type: none;
}
ul li::before {
content: "πΉ";
display: inline-block;
margin-right: 8px;
transition: transform 0.3s ease-in-out;
}
ul li:hover::before {
transform: translateY(-5px);
}
πΎ Result: The bullets will βjumpβ when you hover!
5οΈβ£ Using CSS Counters for Auto-Numbered Lists π’
Want a numbered list but with custom styling? Use CSS counters!
π¨ CSS:
ul {
list-style-type: none;
counter-reset: my-counter;
}
ul li {
counter-increment: my-counter;
}
ul li::before {
content: counter(my-counter) ". ";
color: red;
font-weight: bold;
}
π’ Result:
- First item
- Second item
- Third item
6οΈβ£ Changing Bullet Shapes Dynamically π‘πΌπ·
Make each bullet a different shape!
π¨ CSS:
ul {
list-style-type: none;
}
ul li:nth-child(1)::before {
content: "π΄"; /* Circle */
}
ul li:nth-child(2)::before {
content: "πΊ"; /* Triangle */
}
ul li:nth-child(3)::before {
content: "π·"; /* Diamond */
}
π Result:
π΄ First item
πΊ Second item
π· Third item
π― Final Thoughts
Who knew list bullets could be so much fun? π
Try these out and let me know which one is your favorite! π