selector

class — CSS reference

Matches a class token, not a substring. Multiple class selectors without whitespace require all tokens on the same element.

Formal Syntax & Structure

css syntaxcss
.class-name

Working Example

Example Snippetcss
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Selector lab</title><style>:where(.sample) { color: rgb(32, 32, 32); }.notice { color: rgb(0, 96, 80); }</style></head><body><p id="a" class="sample notice urgent">A</p><p id="b" class="sample noticex">B</p></body></html>
CSS Reference