
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 all <input> elements with an invalid value with 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>
- Related Questions & Answers
- Style all <input> elements with a valid value with CSS
- Style <input> elements with a value outside a specified range with CSS
- Style <input> elements with a value within a specified range with CSS
- Style <input> elements with a "readonly" attribute with CSS
- Style <input> elements with a "required" attribute with CSS
- Style every checked <input> element with CSS
- Style every disabled <input> element with CSS
- Style every enabled <input> element with CSS
- Selects all <div> elements and all <p> elements with CSS
- Selects all <p> elements inside <div> elements with CSS
- Style <input> element with no "required" attribute with CSS
- Style <input> element with no "readonly" attribute with CSS
- Working with <style> element for CSS
- Style every <p> element with a lang attribute value with CSS
- Selects all <p> elements that are placed immediately after <div> elements with CSS
Advertisements