:optional सेलेक्टर का उपयोग
:optional सेलेक्टर उन <input>, <select>, <textarea> एलिमेंट्स को सिलेक्ट करता है जिनमें required एट्रिब्यूट **नहीं** होता। यह वैकल्पिक फील्ड्स को विज़ुअली अलग करने के लिए उपयोगी है।
उदाहरण
<!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>
"Subject" फील्ड ऑप्शनल है (नीला बैकग्राउंड), "Student" रिक्वायर्ड है (स्टाइल नहीं)।