Design comparison
Solution retrospective
is it possible to change placeholder(input) color in js?
Community feedback
- @asmaa-elfatayryPosted about 2 years ago
yes to change the placeholder color using js you can use :
document.getElementById('the-id-name').style.placeholderColor = newColor;
or you can change it directly using CSS
https://www.geeksforgeeks.org/change-an-html5-input-placeholder-color-with-css/
to solve the Accessibility error you should put all the content of the body in the <main></main> tag
https://www.w3.org/WAI/ARIA/apg/example-index/landmarks/main.html#:~:text=The%20main%20landmark%20should%20be%20a%20top-level%20landmark.,main%20landmark%2C%20each%20should%20have%20a%20unique%20label.
Marked as helpful1 - @davinceeyPosted about 2 years ago
Hello @FHER AMABLE RICSE. Great solution you have here (I just completed mine too😆) As concerns your question, it would be preferable if you use CSS Selectors and pseudo elements to change the color of your placeholder. This can be done by using this
::placeholder
. So to change it's color, you do this:::placeholder{ color: black; }
This would enable your Javascript code to be cleaner.
Hope this helps you. Happy Coding!
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