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>