Skip to content

Commit 76c587c

Browse files
committed
fix: add margin-block-start to headings for proper section separation
Headings had margin-block-end (connecting to content below) but no margin-block-start (separating from content above). This caused h3 elements like "Status variants" on the design system page to sit flush against the preceding section. Add margin-block-start: 1.5em to h2-h4 — space scales proportionally with heading size for natural typographic rhythm. h1 is exempted (typically the first element on a page). Add :first-child rule to prevent leading margin when a heading opens its container.
1 parent 6e03ba2 commit 76c587c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/design/base.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
line-height: 1.2;
1313
font-weight: 700;
1414
font-family: var(--font-sans);
15+
margin-block-start: 1.5em;
1516
margin-block-end: 0.5em;
1617
}
17-
h1 { font-size: var(--step-4); line-height: 1.15; }
18+
h1 { font-size: var(--step-4); line-height: 1.15; margin-block-start: 0; }
1819
h2 { font-size: var(--step-3); }
1920
h3 { font-size: var(--step-2); }
2021
h4 { font-size: var(--step-1); }
@@ -83,7 +84,10 @@
8384
small {
8485
font-size: var(--step--1);
8586
}
86-
/* Prevent trailing margin on the last flow element in a container */
87+
/* Prevent leading/trailing margin on first/last flow elements in a container */
88+
:where(h1, h2, h3, h4, p, ul, ol, dl, blockquote, pre):first-child {
89+
margin-block-start: 0;
90+
}
8791
:where(h1, h2, h3, h4, p, ul, ol, dl, blockquote, pre):last-child {
8892
margin-block-end: 0;
8993
}

0 commit comments

Comments
 (0)