Sometimes, we want to select the first element with class with CSS.
In this article, we’ll look at how to select the first element with class with CSS.
How to select the first element with class with CSS?
To select the first element with class with CSS, we the first-of-type
.
For instance, we write
.red:first-of-type {
color: red;
}
to select the first element with class red with .red:first-of-type
.
Conclusion
To select the first element with class with CSS, we the first-of-type
.