1.HTML5 has made many enhancements to the Web Form, such as input type, Form validation, and so on. Placeholder is another property added by HTML5, and when input or textarea is set, the content of the value is displayed as a gray hint in the text box, and the hint text disappears when the text box gets the focus. To achieve this effect in the past is to use JavaScript control to achieve;
2. Since placeholder is a new attribute, only a handful of browsers are currently supported, how can I detect if the browser supports it? (more HTML5/CSS3 feature detection can be accessed)
1 function Hasplaceholdersupport () {2 return in document.createelement (' input '); 3 }
3. The default hint text is gray, you can change the text style through CSS:
1 /* All*/2::-webkit-input-placeholder {color: #f00;}3input:-moz-placeholder {color: #f00;}4 5 /*Individual:webkit*/6#field2::-webkit-input-placeholder {color: #00f;}7#field3::-webkit-input-placeholder {color: #090; background:lightgreen; text-transform:uppercase;}8#field4::-webkit-input-placeholder {font-style:italic; text-decoration:overline; letter-spacing:3px; color: #999; }9 Ten /*Individual:mozilla*/ One#field2:-moz-placeholder {color: #00f;} A#field3:-moz-placeholder {color: #090; background:lightgreen; text-transform:uppercase;} -#field4:-moz-placeholder {font-style:italic; text-decoration:overline; letter-spacing:3px; color: #999;}
HTML5 input placeholder Compatibility processing