Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

3. Forms > 3.10. Displaying Placeholder Text

3.10. Displaying Placeholder Text

Problem

You want to display some hint or help text within a form field.

Solution

The HTML5 placeholder attribute is used to specify instructional text when the user is not focused in the form field:

<form>
    <fieldset>
        <legend>Contact Information</legend>
        <p><label>E-mail address <input type="email" name="email"
            placeholder="user@domain.com"></label></p>
        <p><label>Web site <input type="url" name="website"
            placeholder="http://www.domain.com/"></label></p>
        <p><label>Telephone number <input type="tel" name="phone"
            placeholder="123-123-1234"></label></p>
    </fieldset>
    <p><button type="submit">Submit</button></p>
</form>

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial