Submitted almost 2 years ago
Responsive landing page with button animations and email form validity
@acutr
Design comparison
SolutionDesign
Solution retrospective
Is it possible to add text "check your email please" under the input box if user enters invalid email using only HTML and CSS? I was only able to figure out how to style the input field on invalid entry, but not add text under the input box.
Community feedback
- @amalkarimPosted almost 2 years ago
Yes, it's possible using
:invalid
selector and general sibling selector. First add this:<p class="input-hint">Please provide a valid email address</p>
under or after
<span class="subscribe button">Subscribe</span>
.Then in your css file, add this:
.input-hint { color: red; display: none; } footer input:invalid ~ .input-hint { display: block; }
That should do the trick. Happy coding!
Marked as helpful1@acutrPosted almost 2 years ago@amalkarim Worked like a charm and learned a new thing with the general sibling selector. Thanks!
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord