The element.class selector is a compound selector: a type name and a class with no space between them (for example p.intro or div.card).
It matches only that tag when it also has that class. Use it when the same class name appears on different tags and you want to style one tag only. Compare with a bare .class (any tag) and with a descendant space (p .intro).
Baseline · Widely available.
Not deprecated. Core CSS since CSS1. Extremely broad browser support.
If the wrong elements light up, check these first.
space
No space vs space
p.note is one element. p .note is a descendant. A single space changes the meaning completely.
vs .class
Narrower than a bare class
.note hits every tag. Prefer element.class only when you truly need that tag limit.
specificity
Slightly higher specificity
div.card (0,1,1) beats .card (0,1,0). That can make overrides harder later.
HTML
Class must be on that element
p.intro does not match a p whose child has class intro. The class belongs on the same node.
chain
Multiple classes on one tag
li.a.b requires both classes on the same li. Order in the class attribute does not matter.
Compatibility
Browser Support
The element.class compound selector is a browser CSS selector. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
element.class
Supported everywhere CSS is supported (CSS1-era). Safe for all teaching and production use.
100%Core support
Google Chrome1+
Full support
Mozilla Firefox1+
Full support
Apple Safari1+
Full support
Microsoft Edge12+
Full support
Opera3.5+
Full support
Samsung Internet1+
Full support
Internet Explorer3+
Full support
element.classUniversal
Bottom line: No prefixes. No polyfills. It is not a runtime API.
Remember
Key Takeaways
Role: match one tag only when it also has a given class.
Syntax:tag.class with no space between them.
vs space:p .x is a descendant; p.x is compound.
Tip: prefer bare .class unless you need the tag limit.
One line:element.class means “this tag with this class” — one element, no space.
Frequently Asked Questions
It is a compound selector: a type (tag) name immediately followed by a class, with no space — for example p.intro or div.card. It matches only that tag when it also has that class.
.card matches any element with that class. div.card matches only div elements with that class, so a span.card would not match.
No. p.highlight is one element. p .highlight (with a space) is a descendant selector — a .highlight element nested inside a p.
Yes. div.card is (0,1,1) — one class and one type — so it beats a lone .card at (0,1,0).
Yes. li.spacious.elegant matches an li that has both spacious and elegant in its class list.
Yes. It has been in CSS since CSS1 and is Baseline Widely available. It is a selector pattern, not a Node.js feature.