Skip to content

Reduce default stylesheet specificity to zero - #280

Merged
mbostock merged 2 commits into
observablehq:mainfrom
flcrom:fix/264-zero-specificity
Nov 4, 2026
Merged

mbostock merged 2 commits into
observablehq:mainfrom
flcrom:fix/264-zero-specificity

Conversation

@flcrom

@flcrom flcrom commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #264.

Wrap the default stylesheet selectors in :where(), including selectors inside media rules, so application styles can override them without matching Inputs' selector specificity. Declarations and rule order stay unchanged.

Add a regression test for zero-specificity selectors in both source and minified CSS.

Validation on Node 20:

  • Frozen-lockfile Yarn install, full ESLint and Mocha suite: 194 passing, 3 existing pending tests.
  • Full prepublish build, including Rollup and CSS minification.
  • Chrome checks across desktop, mobile, checked, indeterminate, focus and hover states: default layout and styles unchanged; application overrides work before or after the default CSS, including minified and unminified UMD builds.

Browser checks covered Chrome, not Safari or Firefox.

@mbostock mbostock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably use @layer for this instead, but this is fine for now…

@mbostock
mbostock merged commit a2736a7 into observablehq:main Nov 4, 2026
1 check passed
@Fil Fil mentioned this pull request Nov 11, 2026
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

Successfully merging this pull request may close these issues.

Use :where() to reduce the specificity of default styles to zero

2 participants