Skip to content

Padding of articles removed #662

Todo

Description

@laurentpayot

Bug description: :has(> [class*='margin']) { padding: 0.1px } removes the padding of an article (and other elements) that has a no-margin child

Version: beercss 5.0.3 (still on main in src/cdn/settings/reset.css, lines 58-60)

What happens

reset.css has this rule:

:has(> [class*='margin']) {
  padding: 0.1px;
}

It matches any element with a direct child whose class contains "margin", including no-margin, small-margin, top-margin, etc. Its specificity (0,1,0) is higher than article { padding: var(--_padding) } (0,0,1), so the element loses its own padding.

Minimal reproduction

Codepen here.

<article class="margin border round">
  <p class="no-margin">A sentence that wraps over several lines in a narrow container, so its text reaches the edges of the card.</p>
</article>

Computed padding of the article: 0.1px instead of 1rem. The text touches the border and, with .round (2rem radius), the rounded corners cut into the text on multi-line content.

Without the no-margin class on the <p>, the article keeps its 1rem padding.

Expected

An article keeps its padding whatever the margin helper classes of its children are. If the rule exists to stop margin collapsing, it could be scoped so that it does not override the padding of components (for example :where(:not(article, .card, ...)), or a lower-specificity :where(:has(> [class*='margin']))), or use something that does not change the box, such as display: flow-root.

Workaround

article.my-alert { padding: var(--_padding); }

Activity

  1. added
    bug
    on Nov 13, 2026
  2. Mittalnew commented on Nov 13, 2026

    @Mittalnew

    Hi @laurentpayot, I'd like to fix this. My plan is to narrow the selector in src/cdn/settings/reset.css so it skips no-margin children (e.g. :has(> [class*='margin']:not(.no-margin))) and keeps its specificity at or below article's padding rule, for example with :where(), so the elements keep their own padding. I'll check it against your CodePen and the other *-margin helpers. Could you assign it to me?

  3. laurentpayot commented on Nov 13, 2026

    @laurentpayot
    CollaboratorAuthor

    @Mittalnew Sure, feel free to create a PR for this 👍

  4. added
    next release
    on Nov 27, 2026
  5. added 2 commits that reference this issue on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugnext release

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions