SHARE
Facebook X Pinterest WhatsApp

Create an HTML Email Form Placeholder

Written By
thumbnail
Scott Clark
Scott Clark
Jan 25, 2011

In the past, web developers had to resort to using JavaScript to create minor effects that just made the interaction between website user and website admin easier. The ability to add an email field in a form so that a user could enter their email address is a great example. If the developer wanted to include some sample text in the email field, and then make that text disappear when the user clicked within that form field, they had to use some JavaScript to make it happen. Enter HTML5 and the placeholder attribute–which uses no JavaScript at all!

Another advantage of the new HTML5 placeholder attribute that previously, using JavaScript, once the user deleted the email example text and clicked elsewhere on the page, the input will be remain blank. The placeholder attribute solves this problem, and fills it once again with the sample text.

Keep in mind that some web browsers, such as MSIE 8, Firefox and Opera, don’t currently support the placeholder attribute, but hopeful with another update or two, they will include that support. Either way, using it won’t mess up the page, as those browsers will just ignore it anyway. Here is an example of what the placeholder attribute looks like in action:

For those of you not using compliant browsers, here is a graphic that shows it in action using the Chrome browser:

And here is the HTML5 code that is used to achieve that effect:

<input name="email" type="email" placeholder="user@mydomain.com" />

This is just one example of how the use functionality of HTML5 will simplify the development of web pages that are more user-friendly. Stay tuned for other such examples!

Recommended for you...

Best VR Game Development Platforms
Enrique Corrales
Jul 21, 2022
Best Online Courses to Learn HTML
Ronnie Payne
Jul 7, 2022
Working with HTML Images
Octavia Anghel
Jun 30, 2022
Web 3.0 and the Future Of Web Development
Rob Gravelle
Jun 23, 2022
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.