How do element (type) selectors work in CSS?
An element selector is just the tag name (like p or h1) and it styles every element of that type on the page at once.
p {
color: blue;
}
Write the bare tag name and the rule reaches all matching elements — there is no need to mark them up individually:
<p>This is blue</p>
<p>This is also blue too</p> <!-- both turn blue automatically -->
You can style several tag types with one rule by separating them with commas, which is the standard way to avoid repeating yourself:
h1, h2, h3 {
font-family: Arial, sans-serif;
}
Element selectors are deliberately broad, which means they have low specificity — class and id selectors beat them. That is usually what you want: set sensible defaults per tag, then override the exceptions with classes. The limitation is that styling purely by tag type only gets you so far; for fine-grained control you reach for the class and id selectors below.