How do you put a sentence inside a form field and it disappears when you click inside the field?

Asked

Viewed 104 times

5

I would like to know how to put a sentence inside a form field, and it will disappear when you click inside the field.

How do you do it in CSS? How do you do it?

2 answers

8


There is a property in HTML5 called placeholder who does whatever you want.

<input type="text" placeholder="Digite seu nome" />

1

You can use the placeholder, as stated, or use js and clear the field whenever you click on it.

<input type="text" id="input" value="Value" onClick="func()"/>
<script>
    var func= function(){
        var elem = document.getElementById("input");
        elem.value = "";
    }
</script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.