🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEcss

css Documentation

LOADING ENGINE...

CSS Universal Selector

The power of the asterisk (*). Learn to reset defaults, normalize box models, and master global styling.

style.css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
reset.css
1 / 8
🌍

Tutor:The universal selector, denoted by an asterisk (*), matches absolutely every single element in your document.


Selector Tree

Unlock nodes by mastering Syntax, Resets, Box Models, and Pseudo-elements.

Concept 1: The Syntax

The asterisk * is the universal selector. It selects every single element in the document tree, including html, body, and all descendants.

System Check

Which element does '*' NOT select?


Community Resets

Modern CSS Resets

Most developers now use a custom reset involving * { box-sizing: border-box; }.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

The Universal Selector

Author

Pascual Vila

Frontend Instructor.

The CSS universal selector is denoted by an asterisk *. It matches any and all elements in the document tree. It is a powerful tool primarily used for global resets and normalizing box models.

Syntax and Usage

Simply use the asterisk as the selector:

* {
  margin: 0;
  padding: 0;
}

Common Use Cases

  • CSS Resets: Removing default browser margins and padding to start with a clean slate.
  • Box Sizing: Setting box-sizing: border-box globally to make layout math intuitive.
  • Testing: Quickly visualizing layout structures (e.g., * { outline: 1px solid red }).

Performance & Specificity

The universal selector has a specificity of 0-0-0. This means it is easily overridden by any class, ID, or element selector. While modern browsers handle it well, avoid using it for complex properties (like gradients or shadows) on large pages, as it forces the browser to re-calculate styles for every single node.

Glossary

Wildcard (*)
Another name for the Universal Selector. It acts as a placeholder that matches everything.
CSS Reset
A set of CSS rules (often using *) that resets the styling of all HTML elements to a consistent baseline.
Pseudo-elements
Virtual elements like ::before and ::after. They are NOT selected by * alone; you usually need *, *::before, *::after.