HTML5探索一(那些新增的标签和属性)
tml5相比html4,添加了部分语义化的标签和属性,现在我们就从这些标签和属性开始,学习html5吧。
首先,认识下HTML5新的文档类型:
<!DOCTYPE html>
那些新标签
格式
- <bdi> 定义文本的文本方向,使其脱离其周围文本的方向设置
- <mark> 定义有记号的文本
- <meter> 定义预定义范围内的度量
- <progress> 定义任何类型的任务的进度
- <rp> 定义若浏览器不支持ruby元素显示的内容
- <rt> 定义ruby注释的解释
- <ruby> 定义ruby注释
- <time> 定义日期/时间
- <wbr> 强制定义换行点
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>HTML5 Test Page 1</title>
</head>
<body>
<div><bdi>BDI:在发布用户评论或其他您无法完全控制的内容时,该标签很有用 test</bdi></div>
<hr />
<div><mark>Mark:定义带有记号的文本</mark></div>
<hr />
<div style="width:200px;border:1px solid red;"><meter value="10" />Meter</div>
<hr />
<div><progress value="10" max="100"></progress>Progress: 用于显示进度,结合JS一同使用</div>
<hr />
<div>我在 <time datetime="2008-02-14">情人节</time> 有个约会
<mark>该标签不会再在任何浏览器中呈现任何特殊效果,仅仅方便搜索引擎生成更智能的结果</mark>
</div>
<hr />
<div>
<p>如果想学习 AJAX,那么您必须熟悉 XML<wbr>Http<wbr>Request 对象。</p>
<mark>wbr可强制设置换行点</mark>
</div>
</body>
</html>
表单
- <datalist> 定义下拉列表
- <keygen> 定义生成密钥
- <output> 定义输出的一些类型
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>HTML5 Test Page 2</title>
</head>
<body>
<form method="post">
<p>datalist:和input元素配合,用于定义input可能的值</p>
<input id="lang" list="dl" />
<datalist id="dl">
<option value="C#" />
<option value="Java" />
<option value="PHP" />
</datalist>
<hr />
<p>keygen:提交密钥串到服务器</p>
Username: <input type="text" name="usr_name" />
Encryption: <keygen name="security" />
<input type="submit" />
<hr />
</form>
<p>output:定义不同类型的输出</p>
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">
0
<input type="range" id="a" value="50">100
+<input type="number" id="b" value="50">
=<output name="x" for="a"></output>
</form>
</body>
</html>
图像
- <canvas> 定义图形
- <figcaption> 定义figure元素的标题
- <figure> 定义媒介内容的分组,以及它们的标题
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>HTML5 Test Page 3</title>
</head>
<body>
<div>
<p>canvas:你懂的,画布,各种绚丽效果就靠它了。</p>
<canvas id="c"></canvas>
<script>
var canvas=document.getElementById('c');
var ctx=canvas.getContext('2d');
ctx.fillStyle='#FF0000';
ctx.fillRect(0,0,80,100);
</script>
</div>
<hr />
<div>
<p>
figure: 规定独立的流内容(图像、图表、照片、代码等等),figure 元素的内容应该与主内容相关,但如果被删除,则不应对文档流产生影响。
<br />
figcaption:定义 figure 元素的标题,语义化</p>
<figure>
<figcaption>黄浦江上的的卢浦大桥</figcaption>
<img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSehM_6Bfd79RwCCy1wNj_K6YGEkMsdt0Gekn10Dc6xJ8nxDcS7rg" width="350" height="234" />
</figure>
</div>
</body>
</html>
音频/视频
- <audio> 定义声音内容
- <source> 定义媒介源
- <track> 定义用在媒体播放器中的文本轨道
- <video> 定义视频
链接
- <nav> 定义导航链接
列表
- <command> 定义命令按钮 --注:现在浏览器暂时都不支持
样式/节 -- 语义化标签
- <header> 定义section或page的页眉
- <footer> 定义section或page的页脚
- <section> 定义section
- <article> 定义文章
- <aside> 定义页面内容之外的内容
- <details> 定义元素细节
- <dialog> 定义对话框或窗口
- <summary> 为<details>元素定义可见的标题
编程
<embed> 为外部应用程序(非HTML)定义容器
那些新属性
- contenteditable 规定元素内容是否可编辑
- contextmenu 规定元素的上下文菜单。上下文菜单在用户点击元素时显示
- data-* 用于存储页面或应用程序的私有定制数据
- draggable 规定元素是否可拖动
- dropzone 规定在拖动被多动数据时是否进行复制、移动或链接
- hidden 规定元素仍未或不再相关
- spellcheck 规定是否对元素进行拼写和语法检查
- translate 规定是否应该翻译元素内容
以上全局属性可用于任何HTML元素
参考资料
*:first-child {
margin-top: 0 !important;
}
body>*:last-child {
margin-bottom: 0 !important;
}
/* BLOCKS
=============================================================================*/
p, blockquote, ul, ol, dl, table, pre {
margin: 15px 0;
}
/* HEADERS
=============================================================================*/
h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
padding: 0;
font-weight: bold;
-webkit-font-smoothing: antialiased;
}
h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
font-size: inherit;
}
h1 {
font-size: 28px;
color: #000;
}
h2 {
font-size: 24px;
border-bottom: 1px solid #ccc;
color: #000;
}
h3 {
font-size: 18px;
}
h4 {
font-size: 16px;
}
h5 {
font-size: 14px;
}
h6 {
color: #777;
font-size: 14px;
}
body>h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child {
margin-top: 0;
padding-top: 0;
}
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
margin-top: 0;
padding-top: 0;
}
h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
margin-top: 10px;
}
/* LINKS
=============================================================================*/
a {
color: #4183C4;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
/* LISTS
=============================================================================*/
ul, ol {
padding-left: 30px;
}
ul li > :first-child,
ol li > :first-child,
ul li ul:first-of-type,
ol li ol:first-of-type,
ul li ol:first-of-type,
ol li ul:first-of-type {
margin-top: 0px;
}
ul ul, ul ol, ol ol, ol ul {
margin-bottom: 0;
}
dl {
padding: 0;
}
dl dt {
font-size: 14px;
font-weight: bold;
font-style: italic;
padding: 0;
margin: 15px 0 5px;
}
dl dt:first-child {
padding: 0;
}
dl dt>:first-child {
margin-top: 0px;
}
dl dt>:last-child {
margin-bottom: 0px;
}
dl dd {
margin: 0 0 15px;
padding: 0 15px;
}
dl dd>:first-child {
margin-top: 0px;
}
dl dd>:last-child {
margin-bottom: 0px;
}
/* CODE
=============================================================================*/
pre, code, tt {
font-size: 12px;
font-family: Consolas, "Liberation Mono", Courier, monospace;
}
code, tt {
margin: 0 0px;
padding: 0px 0px;
white-space: nowrap;
border: 1px solid #eaeaea;
background-color: #f8f8f8;
border-radius: 3px;
}
pre>code {
margin: 0;
padding: 0;
white-space: pre;
border: none;
background: transparent;
}
pre {
background-color: #f8f8f8;
border: 1px solid #ccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px;
}
pre code, pre tt {
background-color: transparent;
border: none;
}
kbd {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background-color: #DDDDDD;
background-image: linear-gradient(#F1F1F1, #DDDDDD);
background-repeat: repeat-x;
border-color: #DDDDDD #CCCCCC #CCCCCC #DDDDDD;
border-image: none;
border-radius: 2px 2px 2px 2px;
border-style: solid;
border-width: 1px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
line-height: 10px;
padding: 1px 4px;
}
/* QUOTES
=============================================================================*/
blockquote {
border-left: 4px solid #DDD;
padding: 0 15px;
color: #777;
}
blockquote>:first-child {
margin-top: 0px;
}
blockquote>:last-child {
margin-bottom: 0px;
}
/* HORIZONTAL RULES
=============================================================================*/
hr {
clear: both;
margin: 15px 0;
height: 0px;
overflow: hidden;
border: none;
background: transparent;
border-bottom: 4px solid #ddd;
padding: 0;
}
/* IMAGES
=============================================================================*/
img {
max-width: 100%
}
-->
HTML5探索一(那些新增的标签和属性)的更多相关文章
- h5废弃的标签和属性及新增的标签和属性
一.废弃的标签和属性 1.表现性元素 a) basefont b) big c) center d) font e) strike f) tt 2.框架类元素 a) frame b) frameset ...
- HTML5新增的标签和属性归纳
收集总结的HTML5的新特性,基本除了IE9以下都可以使用. HTML5语法 大部分延续了html的语法 不同之处:开头的 <!DOCTYPE html> <html lang=&q ...
- HTML5新增的标签与属性
一.关于DTD HTML5 不基于 SGML,所以不需要引用 DTD(HTML 4.01 基于 SGML) 二.HTML5结构标签 <header> 标记定义一个页面或一个区域的头部 &l ...
- H5新增的标签和属性
声明 Web 世界中存在许多不同的文档.只有了解文档的类型,浏览器才能正确地显示文档. HTML 也有多个不同的版本,只有完全明白页面中使用的确切 HTML 版本,浏览器才能完全正确地显示出 HTML ...
- html5中常被忘记的标签,属性
placeholder placeholder是input中的属性,就是默认输入的text,当用户输入时,text会被清空. 用法 <input type ="text" p ...
- HTML5新增Canvas标签及对应属性、API详解(基础一)
知识说明: HTML5新增的canvas标签,通过创建画布,在画布上创建任何想要的形状,下面将canvas的API以及属性做一个整理,并且附上时钟的示例,便于后期复习学习!Fighting! 一.标签 ...
- HTML5新增video标签及对应属性、API详解
知识说明: 比不上很牛的前端开发人员,但自始至终明白“万丈高楼平地起”,基础最重要,初学HTML5,稳固基础第一步,把最基本的整理下来,留下自己学习的痕迹.HTML5新增的video标签,将其属性以及 ...
- 重温html5的新增的标签和废除的标签
HTML5已经盛行有段时间了,对于标签的使用,按照规范,哪些该用,哪些不该用,你是否都掌握了呢.今天我在这里详细列举下: 新增的结构标签 section元素 表示页面中的一个内容区 块,比如章节.页眉 ...
- html5 新增语义标签
一份模板: <body> <header> <hgroup> <h1>Page title</h1> <h2>Page subt ...
随机推荐
- IoC实践--用Unity实现MVC5.0的IoC控制反转方法
在MVC中,控制器依赖于模型对数据进行处理,也可以说执行业务逻辑.我们可以使用依赖注入(DI)在控制层分离模型层,这边要用到Repository模式,在领域驱动设计(DDD)中,Repository翻 ...
- ftp如何预览图片 解决方案
下载使用 server-U ,开启 HTTP 服务,输入 http://ip:端口 后,登录ftp账号密码,可选使用 基于java的应用 web client 或 FTP Voyager JV,来预览 ...
- A Brief History of Scaling LinkedIn
原文地址 LinkedIn started in 2003 with the goal of connecting to your network for better job opportuniti ...
- 《CSS 设计指南》学习笔记 一
本篇文章是对这几天看完 Charles Wyke-Smit 的 <CSS 设计指南> 后的一些学习笔记与心得,笔者好像是大一的时候开始接触网页设计,由于并不是计算机专业的,所以所有都是自己 ...
- Android开发:第四日——SQLite初接触
一.SQLite 介绍 SQLite一个非常流行的轻量级嵌入式数据库,SQLite支持多数的SQL92标准,在一些场合下其性能优于MySql等数据库引擎,并且只利用很少的内存就有很好的性能.此外它还是 ...
- 理解 python metaclass使用技巧与应用场景分析
理解python metaclass使用技巧与应用场景分析 参考: decorator与metaclass:http://jfine-python-classes.readthedocs. ...
- 那些一目了然的3D地质模型 【转】
http://www.360doc.com/content/16/0830/09/14719766_586950902.shtml
- 【css】a:hover 设置上下边框在 ie6 和 ie7 下失效
前段时间在写样式的时候发现了这个问题,虽然当时就解决了这个 bug 不过还是记录下,以免再次出现这样的问题. demo 代码: <!doctype html> <html lang= ...
- 在 Excel 中使用正则表达式进行查找与替换
在 Excel 中,使用 Alt+F11 快捷键打开 VBA 项目窗口,在左侧的工作表名称上点右键,选择查看代码,即可出出现右侧的代码编辑窗口 在代码窗口中输入以下代码: Private Sub Re ...
- SAP ECC FI配置文档
SAP ECC 6.0 Configuration Document Financial Accounting (FI) Table of Content TOC \O "1-2" ...