pseudo-class
:only-of-type — CSS reference
Matches an element without same-type siblings, even when siblings of other types exist.
Formal Syntax & Structure
css syntaxcss
:only-of-typeWorking 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); }p:only-of-type { color: rgb(0, 96, 80); }</style></head><body><div><p id="a" class="sample">A</p><span>Other</span></div><div><p id="b" class="sample">B</p><p>Other</p></div></body></html>