InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

HTML tag attributes

  • HTML5 - input placeholder
  • html attribute contenteditable
  • script async attribute
 
  • Home
  • > Tutorials
  • > HTML
  • > HTML tag attribute

HTML5 – input placeholder

on Feb 29, 2016

HTML5 input tag’s placeholder attribute can be used to add a placeholder text (hint which disappears automatically) in input element. Before HTML5 people used to implement it using Jvascript event handers. With HTML5 placeholder attribute, it is very simple and elegant to add placehoder text in input element.

html-input-text-attribute-placeholder

Few things to note about input placeholder

  1. It is used as hint and is not a replacement of label.
  2. Placeholder text disappears the moment user types first character in input field value.
  3. It can be used in input fields where text has to be entered. e.g. where type is text, password, email, etc. It is not relevant for type checkbox, radio, etc.
  4. placeholder also applies to HTML tag textarea.

Basic input placeholder example

<input type="text" name="name" placeholder="FirstName LastName">
<input type="password" name="password" placeholder="Password">
<input type="email" name="email" placeholder="foo@gmail.com">

refresh done
try it online

Styling input placeholder

Input or textarea placeholder text can be styled using css ::placeholder pseudo element style.

Specification and Browser compatibility

SpecificationStatusCategories
input placeholder attributeWHATWG Living StandardHTML5
Desktop
ChromeFirefoxIEEdgeSafariOpera
Yes 4+ Yes 4+ Yes 10+ Yes 12+ Yes 5+ Yes 11.5+
Mobile
Android ChromeAndroid FirefoxiOS SafariIE MobileOpera Mobile
Yes 47+ Yes 44+ Yes 3.2+ Yes 10+ Yes 11+
source: caniuse.com

Suggested posts:

  1. How to install polymer
  2. jQuery ui slider and input text box – one way binding
  3. CSS flexbox – display flex and inline-flex
  4. Monitor apache using mod_status on Ubuntu
  5. CSS box-shadow
  6. HTML5 canvas basic example
  7. Install sass on Mac or Linux using ruby gem
  8. CSS bottom
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged HTML, HTML tag attribute, HTML5, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress