Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rule for nested lists in sanitize.css #243

Open
germanfrelo opened this issue Jun 4, 2024 · 0 comments
Open

Update rule for nested lists in sanitize.css #243

germanfrelo opened this issue Jun 4, 2024 · 0 comments

Comments

@germanfrelo
Copy link

germanfrelo commented Jun 4, 2024

This rule is in sanitize.css:

/**
 * Remove the margin on nested lists in Chrome, Edge, and Safari.
 */

:where(dl, ol, ul) :where(dl, ol, ul) {
  margin: 0;
}

I think it can be updated to:

/**
-* Remove the margin on nested lists in Chrome, Edge, and Safari.
+* Remove the margin on nested lists in Chrome and Edge.
 */

-:where(dl, ol, ul) :where(dl, ol, ul) {
+:where(dir, dl, menu, ol, ul) :where(dir, dl, menu, ol, ul) {
-  margin: 0;
+  margin-block-end: 0;
+  margin-block-start: 0;
}

Explanation:

For one hand, WebKit's UA stylesheet was updated on May 14, 2023 to "Partial Sync UA stylesheet rules as per HTML Spec for 'lists'":

:is(dir, dl, menu, ol, ul) :is(dir, dl, menu, ol, ul) {
    margin-block-start: 0;
    margin-block-end: 0;
}

So I think the ", and Safari" part could be removed from the comment.

On the other hand, Blink (Chrome and Edge) has not yet updated its rule for nested lists:

ol ul, ul ol, ul ul, ol ol {
    margin-block-start: 0;
    margin-block-end: 0
}

which does not include dir, dl, or menu.

The current rule from sanitize.css does include dl, but not dir or menu, as Gecko, WebKit, and the HTML spec do. I suggest changing it to match them all for consistency until Blink is updated.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant