I have a page with about 10 lists, 5 are unordered and 5 are ordered. Rather than the generic disc or bullet/number or Roman numeral I've decided to make up a custom list marker. Each list item is as so...
<ul>
<li>*List Item 1</li>
<li>*List Item 2</li>
</ul>
<ol>
<li>1List Item</li>
<li>1List Item</li>
</ol>
What I need to do is select the initial character being 1, 2 or *. Without using span 100 times or separate stylings for ul
and ol
, is there a way to select the first character.
I have tried using spans but with that many lists and list items there becomes a lot of extra coding...I've also tried
li::first-letter {...}
This works for the ul, but for ol
it results in e.g. "*L" from "*List Item".
I've read a little into ":before", this would probably be the next best thing but I'm hoping there's a selector to do all li's.
Thanks for any info.
EDIT: I have found the solution using a combination of ::first-letter and ::before, like so...
<ul>
<li>List Item</li>
<li>List Item</li>
</ul>
<ol>
<li>1List Item 1</li>
<li>2List Item 2</li>
</ol>
ol li::first-letter, ul li::before {
... // select's all ol and all ul list items
}
ul li::before {
content: "*";
... // adds * as first letter for above
}