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

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

I have an HTML form as follow:

   
Username: Passwor
5条回答
  •  渐次进展
    2021-02-13 11:03

    If you use HTML5 you can do this using the placeholder attribute:

    
         
        
         
        
        
    
    

    I'd still include the Username and Password text wrapped in tags for accessibility, but you could always hide them with some CSS like this:

    form {
        position:relative;
    }
    label {
        position:absolute;
        top:-9999px;
    }
    

提交回复
热议问题