The doubt I have today is a bit curious
I have run into the following problem
I have two span inside a div and I would like to add css to the second span without having to add class or id, can it be done with child?
<div>
<span>color por default</span>
<span>color grey</span>
</div>
div>span{
color: grey;
}
You should use the property
nt:child()
, where within the parentheses is the number of thespan
in your case.He
CSS
would look like this:Use the property
nth-child()
: https://www.w3schools.com/cssref/sel_nth-child.aspIn your case you should do something like this:
I also advise you to add a class to your div, to be more specific. In that case, in the CSS, you just need to add the command
.tuClase
before thespan:nth-child(2)
Greetings.