How to Add a Placeholder with HTML5 to Form Fields
Written by Richi González Sunday, 17 February 2013
Now that HTML5 is becoming more and more compatible with web browsers, you should start thinking of adding placeholders to your form input fields. A placeholder is some text that is displayed when the form field hasn’t been clicked or has content in it. Here we have a picture of what a placeholder looks like in an input field:
Keep reading to learn how to do it by yourself!
1. Declare we are going to use HTML5 in our site by adding the HTML5′s Doctype at the very start of your page, before the <html> tag:
<!DOCTYPE html> <head> ...
2. To add a placeholder to a field, simply add the attribute placeholder to the field, with the regular syntax: attribute=”value”. So if we were to add a placeholder with the value Type something here.. to an input field, we would use the following code:
<input type='text' name='ourtext' placeholder='Type something here..'>
And there you go! Easy, huh? Go try it in your browser so you see how good and professional it looks. If you have any questions, article topic suggestions, please do not hesitate to contact me and I’ll do my best to assist you with anything.
Owner of Juapo2Services
Looking for quality web hosting? Look no further than Arvixe Web Hosting!