selector
attribute — CSS reference
Tests an explicit attribute or its value. Choose an operator that reflects whether the value is a token, whole string, or substring.
Formal Syntax & Structure
css syntaxcss
[attr] / [attr operator value]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); }[data-role="note"] { color: rgb(0, 96, 80); }</style></head><body><p id="a" class="sample" data-role="note">A</p><p id="b" class="sample" data-role="other">B</p></body></html>