First, the problems; explanatory comments are in the code below:
/* there is no <main> element in the posted code, therefore the selector will fail: */ main .works ol li::after { /* there is no defined content property, this is mandatory in order for a pseudo-element to be rendered to the screen, even if only an empty-string */ list-style: icone; position: absolute; } @counter-style icone { system: additive; additive-symbols: V 5, IV 4, I 1; }
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"/> <section class="works"> <h2>Fonctionnement</h2> <ol> <li>Choisissez un restaurant</li> <li>Composez votre menu</li> <li>Dégustez au restaurant</li> </ol> </section>
To rectify the above problems, we remove the main component of the selector and we add an empty-string as a property-value for the declared content property:
.works ol li::after { content: ''; list-style: icone; position: absolute; } @counter-style icone { system: additive; additive-symbols: V 5, IV 4, I 1; }
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" /> <section class="works"> <h2>Fonctionnement</h2> <ol> <li>Choisissez un restaurant</li> <li>Composez votre menu</li> <li>Dégustez au restaurant</li> </ol> </section>
Now that those issues are solved, the demo should...oh, it doesn't?
Well, that's because we also need to use a counter():
@counter-style icone { system: additive; additive-symbols: V 5, IV 4, I 1; } /* we specify that the <ol> element(s) should serve to reset the counter we're using: */ ol { counter-reset: listCounter; inline-size: 15em; } li { position: relative; } .works ol li::after { /* here we define the counter that we're using 'listCounter', and we define the list-style that we wish to use: 'icone'*/ content: counter(listCounter, icone); /* we now specify that the pseudo-element should increment that counter: */ counter-increment: listCounter; position: absolute; /* positioning against the right edge of the nearest non-static ancestor (the <li> in this example): */ right: 0; }
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" /> <section class="works"> <h2>Fonctionnement</h2> <ol> <li>Choisissez un restaurant</li> <li>Composez votre menu</li> <li>Dégustez au restaurant</li> </ol> </section>
References:
@counter-styleworks perfectly well (Firefox 105, Chrome 106 on Ubuntu 22.04). If you're using Safari then you appear to be out of luck, but other browsers (desktop, I've not checked mobile compatibility) seem to work with it.>. Please povide a proper minimal reproducible example when you are asking questions like this.