How do you style the HTML5 form validation messages?
-
Say you have some HTML like this: <form> <input placeholder="Some text!" required> <input type="email" placeholder="An Email!" required> <input type="submit" value="A Button!"> </form> Because of the required attributes, newer Webkits and Firefoxes show a validation message next to the field if you leave it blank. They respond to being styled by a rule such as: div { font: Helvetica; } But I can't find a more specific selector for them. Does anyone know what selector is used, or will be used, or even a bug report for webkit/gecko relating to this? ( JSFiddle showing that they can be styled with a div selector: http://jsfiddle.net/p7kK5/ )
-
Answer:
In the latest iterations of Chrome, support has been added for pseudo selectors for these, namely; ::-webkit-validation-bubble{} ::-webkit-validation-bubble-top-outer-arrow{} ::-webkit-validation-bubble-top-inner-arrow{} ::-webkit-validation-bubble-message{} For more information on these, check out the http://trac.webkit.org/wiki/Styling%20Form%20Controls. Additionally, firefox has support for the element attribute x-moz-errormessage which enables you to change the text of the error message, which is something you could do in Chrome using CSS to and -webkit-validation-bubble-message. See more about https://developer.mozilla.org/en/HTML/element/input#section_5. As of yet, Firefox has no way to style the error bubbles.
Rich Bradshaw at Stack Overflow Visit the source
Other answers
You'll need to use more specific selectors for everything else I'm afraid.. body > div etc.
Sheldon
Related Q & A:
- How To Fill Up Edv Lottery Form?Best solution by mansansaar.blogspot.no
- How does the form validation work on angularjs with ionic?Best solution by blog.nraboy.com
- How can I style the header of dialog?Best solution by Stack Overflow
- How can I style my hair?Best solution by beauty.about.com
- How can I style african american hair?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.