CSS :only-of-type Pseudo-class
Example
Specify a style for any <p>, <li>, and <b> element that is the only child of its type, of its parent:
p:only-of-type {
background-color: red;
}
li:only-of-type {
color: salmon;
}
b:only-of-type {
color: green;
}
Try it Yourself »
Definition and Usage
The :only-of-type
pseudo-class
matches any element that is the only child of its type, of its parent.
Version: | CSS3 |
---|
Browser Support
The numbers in the table specifies the first browser version that fully supports the pseudo-class.
Pseudo-class | |||||
---|---|---|---|---|---|
:only-of-type | 4.0 | 9.0 | 3.5 | 3.2 | 9.6 |
CSS Syntax