Type (Element) Selector
The most straightforward selector is the type selector that targets an element by name, as shown in these examples:
h1 {color: blue;}
h2 {color: blue;}
p {color: blue;}Type selectors can be grouped into comma-separated lists so a single property will apply to all of them. The following code has the same effect as the previous code:
h1, h2, p {color: blue;}CSS 2 introduced a universal element selector (*) that matches any element (like a wildcard).
The style rule * {color: gray} makes
every element in a document gray. The universal selector may be a useful
tool when used in relation to other elements, as discussed in the next
section.
Warning
The universal selector causes problems with form controls in some browsers. If your page contains form inputs, the safest bet is to avoid the universal selector.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access