Why does a tag with the same code fail?

The hover effect of the

div tag is effective. Change to the invalidation solution principle of the p tag?

<!--  -->
<style>
     :root{
         --mainTheme:-sharpf4f4f4;
         --mainFont: -sharp666;
         --dropTheme:yellowgreen;
     }
     body{
         background: var(--mainTheme);
         color: var(--mainFont);

     }
    .dropdown-content { display: none;  background: var(--dropTheme)}
            
    .dropdown:hover .dropdown-content { display: block; }
    </style>
    <!--  -->
    <body>
    <p class="dropdown">
        <span></span>
        <div class="dropdown-content">
        

hello world

</div>

<div class="dropdown"> <span></span> <div class="dropdown-content">

hello world

</div> </div> </body>
Css
Mar.18,2021

there is a problem with the nesting of your tags. The p tag cannot nest div tags, and the browser will parse it into
clipboard.png
pp
,,,

clipboard.png

.
Menu