HTML CSS examples for CSS Selector:optional
The :optional selector selects optional form elements, who do not have required attribute.
The :optional selector only applies to the form elements: input, select and textarea.
Select if the <input> element does not have a "required" attribute:
<!DOCTYPE html> <html> <head> <style> input:optional {<!--from www .j a v a2s . c om--> background-color: yellow; } </style> </head> <body> <input type='text'> <br><input type='text' required> </body> </html>