A list can read as ordinary prose when CSS punctuation is generated by pseudo-elements instead of markup. @ShadowShahriar's CodePen demo does exactly that, placing commas between inline list items so the list renders as a complete, properly punctuated sentence.
Stripping the list presentation
The first step removes everything that makes an unordered list look like a list — markers and spacing — so it behaves as an inline element:
ul {
padding: 0;
margin: 0;
display: inline;
list-style-type: none;
}
The items themselves are displayed inline, which lets them flow as text within a sentence:
li {
display: inline;
}
Generating the punctuation
Commas come from each item's ::after pseudo-element, whose content property is set to a comma (,):
li::after{
content: var(--separator);
}
For the Oxford comma, :nth-last-of-type() targets the second-to-last item, and its ::after content becomes ", and", landing before the final item:
li:nth-last-of-type(2)::after{
content: ", and ";
}
A two-item list needs different treatment: with only a pair of entries, the output should read as an "and" between them:
li:first-of-type:nth-last-of-type(2)::after {
content: " and ";
}
Read through a selector explainer, that compound selector resolves to the after pseudo-element of an <li> that is both the first of its type among its siblings and second from the end:
The
afterpseudo-element… of a
<li>element provided it is the first of its type in its parent and the nth of its type from the end (formula) in its parent.
Finally, a period closes the sentence:
li:last-of-type::after {
content: ".";
}
Separators as custom properties
The actual demo goes further than the excerpts above: both the comma and the conjunction are declared as custom properties, so the separators can later be swapped for other styles.
ul {
--separator: ",";
--connector: "and";
padding: 0;
margin: 0;
display: inline;
list-style-type: none;
}
The technique stays entirely within CSS, supporting semantic HTML without extra classes, elements or JavaScript. The one gap it exposes is markup-level — there is no inline list element (an <il>, say) for carrying list items inside a paragraph.



