Anderson’s answer is the right one, but just to clarify, the way you wrote it #p1:hover #p2 indicates that you are looking for the element #p2 within the element #p1, that is, this CSS indicates that #p1 is the father or ancestor of #p2, but in their HTML they are adjacent brothers, the #p1 is older brother of #p2.
I believe that this is not what you want, but following the logic of what I said above, if #p2 is inside #p1, the code will work. The detail is that like you can’t have a tag <p> into another. Then I put the <p> from within as a <span>, just as an example.
#p2 {
display: none;
}
#p1:hover #p2 {
display: block;
}
<p id="p1">Passe o mouse sobre mim!
<span id="p2">Paragrafo</span>
</p>
A detail: in
#p1 #p2, the element#p1doesn’t have to be necessarily father of#p2, but to be the ancestor of#p2on any level (father, grandfather, great-grandfather, etc). I think using the term "father" would be better just to be#p1 > #p2.– Woss
Hi was that same thanks helped a lot vlw, forgot the css combiners
– user139915
@Andersoncarloswoss really, it does not need to be directly the father, it can be any ancestor, I edited there to be clearer, since I did not use the selector
>– hugocsl
@Leandronascimento tmj my young
– hugocsl