Say, for example purposes I wanted a list of items that each had a different colour bullet point for each item.
The kicker is I need to do this relatively semantically & automatically, avoiding a user having to add a class or a piece of HTML whilst keeping the colour of the text black.
An example:
It poses an interesting problem - How would one go about do this so that a user can simply add a list of items and my code updates them accordingly.
Remove the default bullets, and add bullet characters (U+2022 BULLET or some other) as generated content. You can style the generated content separately. This is flexible and requires no extra markup (beyond some markup that distinguishes between different items, obviously) but has the drawback of failing on old versions of IE (no support to generated content).
Assuming markup
<ul class="mixed">
<li class="red">One.</li>
<li class="green">Two.</li>
</ul>
the style sheet could be
ul.mixed {
list-style-type: none;
}
ul.mixed li:before {
content: "\2022";
padding-right: 0.5em;
}
li.red:before {
color: red;
}
li.green:before {
color: green;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With