日期:2014-05-17  浏览次数:20833 次

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>
?