The universal selector applies its declarations to literally every element on the page, making it the broadest possible selector — it's most commonly seen in CSS reset or normalize stylesheets, applying something like box-sizing: border-box to every element at once, or zeroing out default margin and padding before more specific, intentional styles are layered on top. It carries zero specificity, even lower than a type selector, meaning virtually any other selector, including a plain type selector, easily overrides it.
1Understanding Universal Selectors
The universal selector applies its declarations to literally every element on the page, making it the broadest possible selector — it's most commonly seen in CSS reset or normalize stylesheets, applying something like box-sizing: border-box to every element at once, or zeroing out default margin and padding before more specific, intentional styles are layered on top. It carries zero specificity, even lower than a type selector, meaning virtually any other selector, including a plain type selector, easily overrides it.
The universal selector's zero specificity means it's meant purely as a foundational reset layer — never rely on it for anything you expect to survive being overridden, since essentially any other selector targeting the same element and property will win.
* {
box-sizing: border-box;
}2Practical Example
Here is a real-world application of Universal Selectors showing how it is used in production CSS code.
* {
margin: 0;
padding: 0;
}
h1 {
margin-bottom: 10px;
}3Best Practices
Follow these guidelines when working with Universal Selectors:
1. Use the universal selector primarily for broad, foundational resets, like box-sizing: border-box or zeroing default margins, at the very start of a stylesheet
2. Avoid applying computationally expensive properties broadly via the universal selector on very large, complex pages, since it touches literally every element and can have a measurable performance cost
3. Combine the universal selector with a descendant combinator sparingly, like .container *, since it also matches deeply nested elements you may not have intended to target
Tip: The universal selector's zero specificity means it's meant purely as a foundational reset layer — never rely on it for anything you expect to survive being overridden, since essentially any other selector targeting the same element and property will win.
* {
box-sizing: border-box;
}