CSS的作用:无效的选择器
使用CSS:invalid选择器为所有<input>元素设置无效值的样式。您可以尝试运行以下代码来实现:invalid选择器
示例
<!DOCTYPE html> <html> <head> <style> input:invalid { background: red; } </style> </head> <body> <h2>Heading</h2> <input type = "email" value = "InvalidEmail"> <p>The style (red color background) appears if you type an irrelevant/ invalid email address.</p> </body> </html>