Several methods to realize the prompt function of text box in HTML

Time:2019-12-6

You can use the attribute < input = “text” placeholder = “what you want to enter” >

You can also use js to add CSS Style

Copy code

The code is as follows:

<style type=”text/css”>
.in_search {
border:1 none;
color:#999999;
float:left;
font-size:14px;
height:18px;
line-height:18px;
margin:3px 2px;
width:253px;
}
</style>
< input name = “Q” onfocus = “if (this. Value = = ‘please input what you want’) {this. Value = ‘;}” onblur = “if (this. Value =’) {this. Value = ‘please input what you want’;}” type = “text” value = “please input what you want” / >