Computer >> 컴퓨터 >  >> 프로그램 작성 >> CSS

CSS에서 필수 속성이 없는 스타일 요소

<시간/>

CSS :선택적 선택기를 사용하여 "필수" 속성 없이 요소의 스타일을 지정합니다.

예시

다음 코드를 실행하여 :optional 선택기를 구현할 수 있습니다.

<!DOCTYPE html>
<html>
   <head>
      <style>
         input:optional {
            background-color: blue;
         }
      </style>
   </head>
   <body>
      <form>
         Subject: <input type = "text" name = "subject"><br>
         Student: <input type = "text" name = "student" required><br>
      </form>
   </body>
</html>