Hmtl5 <input>中placeholder属性(新属性)
一、定义和用法
placeholder 属性提供可描述输入字段预期值的提示信息(hint)。
该提示会在输入字段为空时显示,并会在字段获得焦点时消失。
注释:placeholder 属性适用于以下的 <input> 类型:text, search, url, telephone, email 以及 password。
注意:placeholder 属性是 HTML5 中的新属性。
二、示例
代码:
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" contenteditable="true" for="inputUser">用户</label>
<div class="controls">
<input id="inputUser" placeholder="User" type="text" />
</div>
</div>
<div class="control-group">
<label class="control-label" contenteditable="true" for="inputPassword">密码</label>
<div class="controls">
<input id="inputPassword" placeholder="Password" type="password" />
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox" contenteditable="true">
<input type="checkbox" /> Remember me </label>
<button class="btn" contenteditable="true" type="submit">登陆</button>
</div>
</div>
</form>
效果: