How to create an HTML form with pre-filled in “instructions” that clear when a user clicks in the box?

后端 未结 5 1666
眼角桃花
眼角桃花 2021-02-13 10:27

I have an HTML form as follow:

   
Username: Passwor
5条回答
  •  故里飘歌
    2021-02-13 11:05

    As others have noted, there is an attribute in HTML5 that allows this called placeholder - read about it here:

    • http://diveintohtml5.info/forms.html

    • http://dev.w3.org/html5/spec/Overview.html#the-placeholder-attribute

    This does not require Javascript, but it is not supported by older browsers (see http://caniuse.com/#feat=input-placeholder).

    It should be noted that placeholder is not meant to replace s, which you are not using and probably should be.

    Labels are important for a variety of reasons and it is bad practice to not use them.

提交回复
热议问题