I have two questions regarding a login form I’m styling. I am using onfocus to automatically delete text saying ‘Email’ from the box which the user enters their email in and the same for the password box.
- How do I make this text a different colour (i.e. grey) and then the actual input colour black?
- How does this work for the password field which is all stars?
A good example of what I’m trying to achieve is the twitter landing page (minus the more complex fading effects).
Thanks very much.
Just in case you didn’t know…
This is possible without javascript. HTML5 has given us the
placeholderattribute which does exactly what you are asking.Example:
Demo: http://jsfiddle.net/rxfyj/
Browser support is limited, but I think that going forward – this is the best way to implement this functionality, while providing the javascript fallback if absolutely necessary. There are a lot of placeholder plugins out there, but almost all of them I’ve encountered have issues.
More information: http://diveintohtml5.ep.io/detect.html#input-placeholder