HTML5 Placeholder Text

With HTML5 web forms you have the ability to set placeholder text in an input field without using any JavaScript. Placeholder text is displayed inside the input field as long as the field is empty.

To include placeholder text in your form you just need to add the placeholder attribute to you input field, give that a value (e.g. “WDW Rocks!”) and it will give you the desired result.


<form>
  <input name="s" placeholder="WDW Rocks!">
  <input type="submit" value="Search">
</form>

The above renders this:

If the browser doesn’t support the placeholder attribute, it will be ignored. So start using it today!

1 Comment

  1. Public Relations: A communications degree can be excellent preparation
    for entering the public relations field. Handling the outer as well as the inner
    public of the company, forms the duties of the public relation officer.

    People select their product and order it via message.

This post currently has one response. What do you think?

You can use basic HTML when posting code, please turn all < characters into &lt; or > into &gt;
If the code is multi-line, use <pre><code></code></pre>

Leave a Reply

Your email address will not be published. Required fields are marked *