selector

attribute-hyphen — CSS reference

Matches the exact string or a string beginning with that value and a hyphen. Useful for language-tag-like values; use :lang() for inherited language.

Formal Syntax & Structure

css syntaxcss
[attr|="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-lang|="fa"] { color: rgb(0, 96, 80); }</style></head><body><p id="a" class="sample" data-lang="fa-IR">A</p><p id="b" class="sample" data-lang="farsi">B</p></body></html>
CSS Reference