HTML5 新增属性整理


<!DOCTYPE html>
<title>HTML5新增属性</title>
<section>
<article>
<header><h1>autofoucs</h1></header>
<p>
autofoucs可以对input(type='text')、select、textarea与button元素在画面打开时自动获得焦点。
<input type="text" autofocus />
</p>
</article>
<hr/>
<article>
<header><h1>placeholder</h1></header>
<p>
placeholder可以对input(type='text')与textarea添加输入提示。
<input type="text" placeholder="请输入内容" />
</p>
</article>
<hr/>
<article>
<header><h1>form</h1></header>
<div>
可以对input、output、select、textarea、button与fieldset指定form属性,生命它属于哪个表单,然后将其放置在页面上任何位置,而不是表单之内。
<br/>
<form id="form1" action"#"><form>
<label for="username">用户名:</label><input form="form1" id="username" name="username" type="text" />
<label for="password">密码:</label><input form="form1" id="password" name="password" type="password" />
</div>
</article>
<hr/>
<article>
<header><h1>required</h1></header>
<div>
可以对input元素(type=text)与textarea元素指定required属性。该属性表示在用户提交的时候进行检查,检查该元素内一定要有输入内容。
<br/>
<form id="form2" action"#">
<label for="username">用户名:</label><input required id="username" name="username" type="text" />
<label for="password">密码:</label><input required id="password" name="password" type="password" />
<input type="submit" value="保存" />
<form>
</div>
</article>
<hr/>
<article>
<header><h1>autocomplete</h1></header>
<div>
可以设置input(type=text)在输入时,是否显示之前的输入项。可以应用在登录用户处,避免安全隐患。
<br/>
<form id="form3" action="#">
<label for="autocomplete_off" >autocomplete="off"</label><input type="text" id="autocomplete_off" autocomplete="off" />
<label for="autocomplete_on" >autocomplete="on"</label><input type="text" id="autocomplete_on" autocomplete="on" />
</form>
</div>
</article>
<article>
<header><h1>min、max、step</h1></header>
<div>
min与max这两个属性是数值类型或日期类型的input元素的专用属性,它们限制了在input元素中输入的数值与日期的范围。
<br/>
<input type="number" min="0"/>
<input type="number" max="100" />
</div>
</article>
<article>
<header><h1>step</h1></header>
<div>
step属性控制input元素中的值增加或减少时的步幅。
<br/>
<input type="number" step="5" />
<div>
</article>
<article>
<header><h1>multiple</h1></header>
<div>
在选择文件时可以选择多个文件。
<input type="file" multiple />
</div>
</article>
<article>
<header><h1>pattern</h1></header>
<div>
通过一个正则表达式来验证输入内容。
<input type="text" required pattern="[0-9][A-Z]{3}" name="pattern" />
</div>
</article>
<article>
<header><h1>formaction、formenctype、formmethod、formnovalidate、formtarget</h1></header>
<div>
为input元素与button元素增加了新属性:formaction、formenctype、formmethod、formnovalidate、formtarget,他们可以重载form元素的action、enctype、method、novalidate鱼target属性。
</div>
</article>
<article>
<header><h1>disabled</h1></header>
<p>
为fieldset元素增加了disabled属性,可以把它的子元素设为disabled状态。
</p>
</article>
<article>
<header><h1>novalidate</h1></header>
<div>
为input、button、form增加了novalidate属性,该属性可以取消提交时进行的有关检查,表单可以被无条件的提交。
</div>
</article>
</section>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值