Change bullets color of an HTML list without using span
Want to change the bullet color in a list swiftly? The CSS ::marker
pseudo-element is the answer:
This nifty property makes the bullets sport a new color while the list text color remains unchanged.
Custom bullet colors using pseudo-elements
Now, let's sail further. If you require more control over bullet appearance, there is another robust method involving ::before
pseudo-element:
The list-style
set to none will remove the default bullets while the ::before
pseudo-element creates the new, manipulative bullets.
Keeping compatibility in check
It's cool to use ::marker
for clarity but do remember the browser support limitations. Targeting older browsers like IE? Then the ::before
pseudo-element is your trusty sidekick:
Using an SVG provides a raft of options but do remember to URI encode it and avoid any misrendering kerfuffles.
Visuals make it fun
Visualizing concepts makes learning enjoyable. Let us learn how to color list bullets, without the help of span
:
The way to color these bullets without touching the balloons is:
And voilà! Our list bullets have changed color meanwhile the text color remains unaffected. Quite mesmerizing, right? 🎨🖌️
Crafting fancy custom bullets with CSS3
Why settle for ordinary? Create custom-styled bullets to make your lists distinctive. CSS3 and its features like border-radius
might help your cause along with -moz-background-clip
for cross-browser compatibility:
Maintain an immaculate balance between the creations and item text for a perfect readability and layout.
Was this article helpful?