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

บทบาทของ CSS :ตัวเลือก Selector


ใช้ CSS :ตัวเลือกตัวเลือกเพื่อจัดรูปแบบองค์ประกอบ โดยไม่มีแอตทริบิวต์ "จำเป็น"

ตัวอย่าง

คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้งาน :ตัวเลือกตัวเลือก:

<!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>