CKTIS / CSS
Type selector
A type selector selects elements by tag name, such as p or button. It matches every element of that type within the matching scope, regardless of its classes and IDs.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
element { property: value; }A type selector is an element type name, such as p, button, or article. In element { property: value; }, element is a placeholder for an actual tag name, not a CSS keyword meaning any element. Use the universal selector * for any type.
The rule p { color: blue; } selects every matching p element, not just the first. It does not select an element merely because it has class="p" or id="p"; those require .p and #p, respectively. The selector p.notice requires both type p and class notice. A type selector alone has specificity (0, 0, 1); matching does not guarantee that its declaration wins the cascade.
In HTML documents, the names of HTML elements are matched ASCII case-insensitively. Foreign elements, such as those in inline SVG, can require an exact case match. In XML documents, element names are case-sensitive. An optional namespace prefix gives ns|element, where ns must be declared. *|element allows any namespace, and |element requires no namespace. Without a default namespace, bare element is equivalent to *|element; when a default namespace is declared, it is restricted to that namespace.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Type selector</title>
<style>
body { color: rgb(0, 0, 0); }
p { color: rgb(0, 0, 255); }
</style>
<p id="first">Alpha</p>
<span id="other">Beta</span>
<p id="last">Gamma</p>
</html>Result
#first: rgb(0, 0, 255) #other: rgb(0, 0, 0) #last: rgb(0, 0, 255)
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.