
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Style Input Elements with Invalid Value Using CSS
To style all <input> elements with an invalid value, use the CSS :invalid selector.
Example
You can try to run the following code to implement the :invalid selector −
<!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>
Advertisements