I have 5 paragraphs and a paragraph nested in a div like in the code below, the problem is with p:hover{background-color: gray;}
, it should change the background of all paragraphs but it doesn't change the ones which have id attribute or are nested inside a div which has id attribute.
p {
background-color: brown;
padding: 10px;
}
.p1 {
background-color: darkcyan;
}
.p2 {
background-color: darkmagenta;
color: white;
}
#p1 {
background-color: royalblue;
color: white;
}
#p2 {
background-color: orangered;
}
#d1 {
background-color: darkgreen;
padding: 5px;
}
#d1 p {
background-color: yellowgreen;
}
p:hover {
background-color: gray;
}
<p>This is a normal paragraph</p>
<p class="p1">This is a paragraph with class attribute "p1"</p>
<p class="p2">This is a paragraph with class attribute "p2"</p>
<p id="p1">This is a paragraph with id attribute "p1"</p>
<p id="p2">This is a paragraph with id attribute "p2"</p>
<div id="d1">
<p>This is a paragraph nested in a div of id equal to "d1"</p>
</div>