Description
Using list-style-position: outside;
with ordered lists commonly leads to issues where the ::marker
overflows the edge of the viewport because the size of the ::marker
is not always the same.
To fix this you can use list-style-position: inside;
but then the alignment of all of the list's ::marker
s is ruined. So to fix the alignment the first thing that came to my mind (and others) is to use subgrid like this:
:is(ul, ol) {
padding: 0;
list-style-position: inside;
display: grid;
grid-template-columns: min-content 1fr;
> li {
align-items: baseline;
grid-column: 1 / -1;
display: block grid list-item;
grid-template-columns: subgrid;
> * {
grid-column: 2 / -1;
}
}
}
But unfortunately according to the spec this isn't currently allowed:
Note: In this level, as restricted in the grammar, list-items are limited to the Flow Layout display types (block/inline/run-in with flow/flow-root inner types). This restriction may be relaxed in a future level of this module.
— The note from 2.3. Generating Marker Boxes: the list-item keyword in CSS Display Module Level 3
This restriction means using display: block grid list-item;
to fix the alignment issue is not allowed. So I would love to see the list-item display type limitations relaxed so this is possible!