Home > Article > Web Front-end > What is the use of invalid selector?
The role of the invalid selector is to set a specific style when an illegal value is entered in the form element. The purpose is to remind the user that the entered value is incorrect.
The :invalid selector in CSS is mainly used Sets the specified style when the value in the form element is illegal.
【Recommended course: CSS Tutorial】
Example: When the user input is not a legal value, the style will change to a red border
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style> input:invalid { border:2px solid red; } </style> </head> <body> <input type="email" value="" /> <p>请输入合法 e-mail 地址,查看样式变化。</p> </body> </html>
Rendering:
The above is the detailed content of What is the use of invalid selector?. For more information, please follow other related articles on the PHP Chinese website!