HTML placeholder Attribute

HTML placeholder Attribute: This attribute is defined as a short hint that describes the expected value of an input field or area. While the short hint is displayed in the field before the user enters a value. The image will not get displayed properly because of the following reasons:

  • Network failure
  • Slow connection
  • Source attribute path errors

HTML placeholder Attribute

This attribute can be applied to <input>,<textarea> elements.

Browser Support

This attribute is supported by the following browsers:

  • Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera

Example: for <input> element

<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
  <input type="text" name="fname" placeholder="First name"><br>
  <input type="text" name="lname" placeholder="Last name"><br>
  <input type="submit" value="Submit">
</form>
</body>
</html>

Output:

html placeholder attribute

Example: for <textarea> element

<!DOCTYPE html>
<html>
<body>
<textarea rows="4" cols="50" placeholder="Describe yourself here..."></textarea>
</body>
</html>

Output:

html placeholder attribute