HTML CSS examples for CSS Selector:required
The :required selector selects required form elements, who have the required attribute.
The :required selector only applies to the form elements: input, select and textarea.
Select only if the <input> element has a "required" attribute:
<!DOCTYPE html> <html> <head> <style> input:required {<!-- w ww .ja va2 s .c om--> background-color: yellow; } </style> </head> <body> <input type='text'> <input required> </body> </html>