0

Im trying to add css to a specific element by its class, but only the the first instance of it. I tried using first-type-of, nth-type-of, didn't get the result I was expecting.

<style>
.test:first-of-type {
    color:red;
}
</style>

<div class='parent'>
 <div>
   <div class='bblalba'></div>
   <div class='test'>Hello1</div>
   <div class='test'>Hello2</div>
 </div>
<div>

Lets suppose for example I want the Hello1 text to be red.

  • Do not use an `id` multiple times. See [this question](https://stackoverflow.com/questions/192048/can-an-html-element-have-multiple-ids). – InSync Mar 26 '23 at 10:44

0 Answers0