selector

attribute-prefix — CSS reference

Matches a nonempty prefix of the attribute string, regardless of token boundaries. An empty search string matches nothing.

Formal Syntax & Structure

css syntaxcss
[attr^="prefix"]

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-new">A</p><p id="b" class="sample" data-role="old-note">B</p></body></html>
CSS Reference