CKTIS / CSS
Class selector
The `.class` selector selects elements belonging to a named class. In HTML it matches an individual token in the `class` attribute, not a substring.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
.class { property: value; }A .class selector is a dot immediately followed by a CSS identifier. In HTML standards mode, .note matches the same elements as [class~="note"]: it matches the token note, not notebook. Names requiring special CSS spelling must use escapes.
.note.important requires both classes on one element; .note .important selects a descendant. Token order in class does not matter.
The specificity of .note is (0,1,0); .note.important has (0,2,0). In standards mode, both .note and [class~="note"] match case-sensitively. In quirks mode, class selectors match ASCII case-insensitively, but the unflagged attribute selector [class~="note"] remains case-sensitive.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Class selector</title>
<style>
p { color: black; }
.note { color: blue; }
.note.important { color: red; }
</style>
<p class="note">A</p>
<p class="important note">B</p>
<p class="notebook">C</p>
</html>Result
A: blue B: red C: black
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.