sindresorhus / modern-normalize

🐒 Normalize browsers' default style
MIT License
6.16k stars 358 forks source link

Make it easier to override `tab-size` #50

Closed nuxodin closed 3 years ago

nuxodin commented 3 years ago

change :root to html because :root has a higher specificity than html

sindresorhus commented 3 years ago

What's the benefit of lower specificity? I don't see how anyone would care to override this.

nuxodin commented 3 years ago

If you want to override tab-size for a specific element, for example a custom element, :root wins.

:root {
    tab-size: 4;
}
custom-pre { /* does not overwrite */
    tab-size: 3;
}

I don't see any reason to use :root.

And you save one byte :)

sindresorhus commented 3 years ago

From the original issue (https://github.com/sindresorhus/modern-normalize/issues/17):

Using :root so users can easily override it on a per-element basis.

Either I was confused back then or we're missing something now.

nuxodin commented 3 years ago

My wisdom comes from here: https://css-tricks.com/a-complete-guide-to-custom-properties/#the-root-thing

And it makes sense, :root is a pseudo class and has 0.1.0 specificity where html has 0.0.1