First, start with valid HTML; an <li>
element must be a descendant of either a <ul>
or <ol>
, for some reason you've reversed that wrapping. Corrected, it should like:
::marker {
color: red;
}
<ol>
<li>My name is Osirin. I'm 23 and currently studying Computer Science in college. I'm a bit late starting third level as I had a few issues in secondary school. Despite this, I'm committed to finishing my degree and working abroad in the States for Google.</li>
</ol>
Here, we use the ::marker
pseudo-element to style the markers of all <li>
elements within the document; to style those of <ol>
and <ul>
differently, we can instead:
ol li::marker {
color: red;
}
ul li::marker {
color: purple;
}
<ol>
<li>My name is Osirin. I'm 23 and currently studying Computer Science in college. I'm a bit late starting third level as I had a few issues in secondary school. Despite this, I'm committed to finishing my degree and working abroad in the States for Google.</li>
</ol>
<ul>
<li>My name is Osirin. I'm 23 and currently studying Computer Science in college. I'm a bit late starting third level as I had a few issues in secondary school. Despite this, I'm committed to finishing my degree and working abroad in the States for Google.</li>
</ul>
In the event that you choose not to use the default list-marking, and use list-style-none
on the <li>
, <ul>
or <ol>
elements, and use CSS generated-content the ::marker
pseudo-element will be removed, and instead you'd have to style the color
specifically, as so:
*, ::before, ::after {
box-sizing: border-box;
font: 1rem / 1.5 sans-serif;
margin: 0;
padding: 0;
}
ol, ul, li {
list-style-type: none;
}
ul, ol {
counter-reset: listCounter;
}
li::before {
content: counter(listCounter);
color: lime;
margin-inline: 1em;
}
<ol>
<li>My name is Osirin. I'm 23 and currently studying Computer Science in college. I'm a bit late starting third level as I had a few issues in secondary school. Despite this, I'm committed to finishing my degree and working abroad in the States for Google.</li>
</ol>
<ul>
<li>My name is Osirin. I'm 23 and currently studying Computer Science in college. I'm a bit late starting third level as I had a few issues in secondary school. Despite this, I'm committed to finishing my degree and working abroad in the States for Google.</li>
</ul>