使用CSS选择 <div>元素内的所有 <p>元素

使用 元素元素选择器选择另一个元素内的所有元素。

您可以尝试运行以下代码来实现元素元素选择器,

示例

<!DOCTYPE html>
<html>
   <head>
      <style>
         div p {
            color: white;
            background-color: blue;
         }
      </style>
   </head>
   <body>
      <h1>Demo Website</h1>
      <h2>Fruits</h2>
      <p>Fruits are good for health.</p>
      <div>
         <p>This is demo text.</p>
      </div>
   </body>
</html>