CSS :optional 選擇器的作用
使用 CSS :optional 選擇器對沒有 "required" 屬性的 <input> 元素設定樣式
示例
你可以嘗試執行以下程式碼來實現 :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>
廣告