Skip to main content
CSS Tip

The shortest selector for the root element

To target the html element, you either use "html{}" or ":root{}" but thanks to CSS nesting you can simply use "&{}"

When used alone, the nesting selector will match the root element!

A one-character selector 🤯

⚠️ It has a lower specificity than html and :root

& {
font-family: sans-serif;
background: #25fca4;
--variable: value;
/* and so on */
}
/* same as html {} and :root {}
with a lower specificity!
*/

More CSS Tips