Type Selector
W3C CSS Snapshot 2026
A type selector matches elements by their tag name.
On this page
Syntax and values
| Value or syntax | What it does |
|---|---|
p | Matches paragraph elements. |
h2 | Matches level-two headings. |
Try the example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Type Selector</title>
<style>
p { color: teal; }
</style>
</head>
<body>
<p class="notice">Registration opens Monday.</p>
<p id="location">Meet in Room 2.</p>
<h2>Workshop</h2>
</body>
</html>
What to expect Both paragraphs turn teal. Change p to h2 to style the heading.