HTML5新特性新标签新属性看这一篇就够了

部分资料参考百度百科

HTML历史上有如下版本:
①HTML 1.0:在1993年6月作为互联网工程工作小组(IETF)工作草案发布。
②HTML 2.0:1995年1 1月作为RFC 1866发布,于2000年6月发布之后被宣布已经过时。
③HTML 3.2:1997年1月14日,W3C推荐标准。
④HTML 4.0:1997年12月18日,W3C推荐标准。
⑤HTML 4.01(微小改进):1999年12月24日,W3C推荐标准。
⑥HTML 5:HTML5是公认的下一代Web语言,极大地提升了Web在富媒体、富内容和富应用等方面的能力,被喻为终将改变移动互联网的重要推手。

HTML5的新特性:

在这里插入图片描述

新标签:

<header>定义头部,页眉</header>
<nav>定义导航栏</nav>
<footer>定义底部,页脚</footer>
<article>定义文章</article>
<section>文章中的小节,小区块</section>
<aside>侧边,文章外部分</aside>

<datalist>:定义选项列表

<input type="text" value="输入语言" list="lan"/>
<datalist id="lan">
<option>java</option>
<option>c</option>
<option>c++</option>
</datalist>

注意需要链接输入框和datalist,用id链接,input 后属性list="#id"
演示效果:
在这里插入图片描述
在这里插入图片描述
且具有默认提示效果。

<fieldset>可将表单内的相关元素分组,打包:

在这里插入图片描述

<fieldset>
	<legend>用户登录</legend>
	用户名:<input type="text" />
	密码:<input type="text" />
</fieldset>

新增input type 属性值:

email :

<fieldset>
	<legend>html5 new input type</legend>
	<form action="">
	邮箱<input type="email" /><br/>
	<input type="submit" />
	</form>
</fieldset>

Email属性包含基本判断,提交时会判断@符号。
在这里插入图片描述

tel:

输入手机号码格式,pc端无特殊,移动端显示数字键盘

number:

只能输入显示数字格式,其他格式无法显示。

url:

在这里插入图片描述
仍然包括基础判断。

<fieldset>
	<legend>html5 new input type</legend>
	<form action="">
	网址<input type="url" /><br/>
	<input type="submit" />
	</form>
</fieldset>

search搜索框:

增加删除功能
在这里插入图片描述

range滑块:

在这里插入图片描述

与时间相关的属性值time,date,datetime,month,week:

在这里插入图片描述

    <input type="time" ><br/>
	<input type="date" ><br/>
	<input type="datetime" ><br/>
	<input type="month" ><br/>
	<input type="week" ><br/>

在这里插入图片描述
附带选择功能。

placeholder占位符/autofocus自动获取焦点:

当输入时,文字消失

在这里插入图片描述

<fieldset>
	<legend>html5 new input type</legend>
	<form action="">
	邮箱<input type="email" placeholder="输入邮箱" autofocus="autofocus"/><br/>
	
	</form>
</fieldset>

multiple上传:

在这里插入图片描述

<fieldset>
	<legend>html5 new input type</legend>
	<form action="">
	上传<input type="file" multiple/>
	</form>
</fieldset>

可进行多选上传,效果如下:
在这里插入图片描述

autocomplete自动补全:

<form action="">
	姓名:<input type="text" autocomplete="on" name="username"/>
	<input type="submit">
	</form>

在这里插入图片描述
在这里插入图片描述
首先触发的前提是提交过数据,故必须要有一个输入框和一个提交按钮,且数据有自己的name值,如上为username。

required必填项:

存在一定兼容性问题,火狐浏览器正常显示,Google不存在效果,但可以取到不同的值

accesskey规定激活:

使某一元素获得焦点的快捷键,采用alt+规定字母。

<form action="">
	姓名:<input type="text" autocomplete="on" name="username" accesskey="s"/><br>
	<input type="submit">
	
</form>

设置s为快捷键,当alt+s时,会自动获得焦点。
在这里插入图片描述

原创文章 171 获赞 72 访问量 5万+

猜你喜欢

转载自blog.csdn.net/qq_43277404/article/details/104984190