tag
The type selector picks every element with the given tag; the universal selector `*` picks every element.
Syntax
p { … } * { … }Parameters
| Parameter | Type | Description |
|---|---|---|
| tag | name | A tag name without angle brackets: `p`, `h1`, `button`. |
| * | universal | Matches any element. |
Examples
All paragraphs get one color:
<style>
p { color: steelblue; }
h3 { margin: 0; }
</style>
<h3>Title</h3>
<p>Every paragraph is blue.</p>
<p>This one too.</p>* is often used for a reset that applies to the whole page:
<style>
* { box-sizing: border-box; }
div { width: 200px; padding: 20px; background: khaki; }
</style>
<div>Exactly 200px wide, padding included</div>Notes
Type selectors have the lowest specificity, so they are good for base styles: a class rule overrides them easily. Do not style everything through tags — a component styled with div alone breaks as soon as another div appears nearby.
See also
In the tutorial
- Selectors — How to pick elements for styling — by tag, class, id, nesting and attribute.