Skip to content

[css-display-4] Relax list-item display type limitations #12100

Open
@EllyLoel

Description

@EllyLoel

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 ::markers 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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions