Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

tag

The type selector picks every element with the given tag; the universal selector `*` picks every element.

Syntax

p { … }  * { … }

Parameters

ParameterTypeDescription
tagnameA tag name without angle brackets: `p`, `h1`, `button`.
*universalMatches 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

  • .class — Selects elements that have the given class in the `class` attribute.
  • #id — Selects the single element with the given `id` attribute.
  • A, B — A selector list: one rule for several selectors separated by commas.

In the tutorial

  • Selectors — How to pick elements for styling — by tag, class, id, nesting and attribute.

Thanks for reading!

Donate to the site — we work hard for you.