html5中,在新增加和废除很多元素的同时,也增加和废除了很多属性。

1、表单属性

a、autofocus

对input[所有类型]、select、textarea与button指定autofocus属性。它以指定属性的方式让元素在页面加载后自动获得焦点。一个页面只能有一个元素有autofocus属性,同时设置多个,则第一个生效。

这个属性对登录页面很有用,可提升用户体验,有时登录页面就一个用户名,密码,页面加载后用户要手动定位到输入框,才能输入,有了autofocus,页面打开即可直接输入。

举例:

<form>
<p>用户名:<input type="text" autofocus /></p>
<p>&nbsp;&nbsp;码:<input type="password"/></p>
</form>

html5新增及废除属性

b、placeholder

对input[text, search, url, telephone, email 以及 password]、textarea指定placeholder属性,它会对用户的输入进行提示,提示用户期待什么样的输入。

当输入框获取焦点时,提示字符消失。

这个属性也能提升用户体验,用的已经相当普遍了。

举例:

<form>
<p>用户名:<input type="text" autofocus placeholder="用户名"/></p>
<p>&nbsp;&nbsp;码:<input type="password" placeholder="密码"/></p>
</form>
View Code

相关文章:

  • 2021-08-02
  • 2021-11-27
  • 2021-12-13
  • 2021-08-07
  • 2021-06-10
  • 2021-11-05
  • 2021-12-07
猜你喜欢
  • 2021-11-04
  • 2022-01-01
  • 2021-10-02
  • 2021-11-27
  • 2021-11-27
  • 2021-11-27
  • 2021-11-27
  • 2021-10-02
相关资源
相似解决方案