Tsallaka zuwa abun ciki
Justice Tech School

Universal and Grouping Selectors

The universal selector * matches every element. It is often used for resets such as box-sizing. A comma groups selectors so one block of declarations applies to all of them.

Grouping avoids repeating yourself: h1, h2, h3 { color: navy; } is the same as writing three separate rules.

Example
<style>
  * { font-family: sans-serif; }
  h1, h2, .accent { color: teal; }
</style>
<h1>Heading one</h1>
<h2>Heading two</h2>
<p class="accent">Accent paragraph</p>
<p>Ordinary paragraph</p>

Exercise

Style h1 and h2 together by separating them with a comma.

h1 h2 {
  color: green;
}

Quiz Test

What does the selector * match?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.