Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

จัดรูปแบบทุก

องค์ประกอบที่ไม่มีลูกด้วย CSS


หากต้องการจัดรูปแบบทุก

องค์ประกอบที่ไม่มีลูกด้วย CSS ให้ใช้:ตัวเลือกที่ว่างเปล่า t คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้งาน:ตัวเลือกว่าง

ตัวอย่าง

<!DOCTYPE html>
<html>
   <head>
      <style>
         p.demo {
            width: 300px;
            height: 20px;
            background: gray;
         }
         p:empty {
            width: 150px;
            height: 20px;
            background: orange;
         }
      </style>
   </head>
   <body>
      <p class = "demo">This is demo text. Below is empty text.</p>
      <p></p>
   </body>
</html>