tml5相比html4,添加了部分语义化的标签和属性,现在我们就从这些标签和属性开始,学习html5吧。

首先,认识下HTML5新的文档类型:

<!DOCTYPE html>

那些新标签

格式

  1. <bdi> 定义文本的文本方向,使其脱离其周围文本的方向设置
  2. <mark> 定义有记号的文本
  3. <meter> 定义预定义范围内的度量
  4. <progress> 定义任何类型的任务的进度
  5. <rp> 定义若浏览器不支持ruby元素显示的内容
  6. <rt> 定义ruby注释的解释
  7. <ruby> 定义ruby注释
  8. <time> 定义日期/时间
  9. <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>

表单

  1. <datalist> 定义下拉列表
  2. <keygen> 定义生成密钥
  3. <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>

图像

  1. <canvas> 定义图形
  2. <figcaption> 定义figure元素的标题
  3. <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>

音频/视频

  1. <audio> 定义声音内容
  2. <source> 定义媒介源
  3. <track> 定义用在媒体播放器中的文本轨道
  4. <video> 定义视频

链接

  1. <nav> 定义导航链接

列表

  1. <command> 定义命令按钮 --注:现在浏览器暂时都不支持

样式/节 -- 语义化标签

  1. <header> 定义section或page的页眉
  2. <footer> 定义section或page的页脚
  3. <section> 定义section
  4. <article> 定义文章
  5. <aside> 定义页面内容之外的内容
  6. <details> 定义元素细节
  7. <dialog> 定义对话框或窗口
  8. <summary> 为<details>元素定义可见的标题

编程

<embed> 为外部应用程序(非HTML)定义容器

那些新属性

  1. contenteditable 规定元素内容是否可编辑
  2. contextmenu 规定元素的上下文菜单。上下文菜单在用户点击元素时显示
  3. data-* 用于存储页面或应用程序的私有定制数据
  4. draggable 规定元素是否可拖动
  5. dropzone 规定在拖动被多动数据时是否进行复制、移动或链接
  6. hidden 规定元素仍未或不再相关
  7. spellcheck 规定是否对元素进行拼写和语法检查
  8. translate 规定是否应该翻译元素内容

以上全局属性可用于任何HTML元素

参考资料

  1. http://www.w3schools.com/tags/

*: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探索一(那些新增的标签和属性)的更多相关文章

  1. h5废弃的标签和属性及新增的标签和属性

    一.废弃的标签和属性 1.表现性元素 a) basefont b) big c) center d) font e) strike f) tt 2.框架类元素 a) frame b) frameset ...

  2. HTML5新增的标签和属性归纳

    收集总结的HTML5的新特性,基本除了IE9以下都可以使用. HTML5语法 大部分延续了html的语法 不同之处:开头的 <!DOCTYPE html> <html lang=&q ...

  3. HTML5新增的标签与属性

    一.关于DTD HTML5 不基于 SGML,所以不需要引用 DTD(HTML 4.01 基于 SGML) 二.HTML5结构标签 <header> 标记定义一个页面或一个区域的头部 &l ...

  4. H5新增的标签和属性

    声明 Web 世界中存在许多不同的文档.只有了解文档的类型,浏览器才能正确地显示文档. HTML 也有多个不同的版本,只有完全明白页面中使用的确切 HTML 版本,浏览器才能完全正确地显示出 HTML ...

  5. html5中常被忘记的标签,属性

    placeholder placeholder是input中的属性,就是默认输入的text,当用户输入时,text会被清空. 用法 <input type ="text" p ...

  6. HTML5新增Canvas标签及对应属性、API详解(基础一)

    知识说明: HTML5新增的canvas标签,通过创建画布,在画布上创建任何想要的形状,下面将canvas的API以及属性做一个整理,并且附上时钟的示例,便于后期复习学习!Fighting! 一.标签 ...

  7. HTML5新增video标签及对应属性、API详解

    知识说明: 比不上很牛的前端开发人员,但自始至终明白“万丈高楼平地起”,基础最重要,初学HTML5,稳固基础第一步,把最基本的整理下来,留下自己学习的痕迹.HTML5新增的video标签,将其属性以及 ...

  8. 重温html5的新增的标签和废除的标签

    HTML5已经盛行有段时间了,对于标签的使用,按照规范,哪些该用,哪些不该用,你是否都掌握了呢.今天我在这里详细列举下: 新增的结构标签 section元素 表示页面中的一个内容区 块,比如章节.页眉 ...

  9. html5 新增语义标签

    一份模板: <body> <header> <hgroup> <h1>Page title</h1> <h2>Page subt ...

随机推荐

  1. Delphi 如何让程序获取权限结束指定进程?

    比如说让程序结束进程中360sd.exe 获取权限,否则会拒绝访问, 要怎么写?   补充: 这段代码中……点击按钮后结束不了360进程! unit Unit1;interfaceusesWindow ...

  2. 简述Java内存模型的由来、概念及语义

    JDK5引入了JMM新规范:JSR-133,引入了happens-before/可见性等概念,对synchronized/volatile/final等关键词进行了语义定义.解决了:final变量在构 ...

  3. CSS等高布局

    做一些后台项目,和一下带侧边栏项目的时候登高布局很常用,总结了下有几种 1.margin-bottom方法 这里直接介绍我认为的最佳的侧边栏/分栏高度自动相等方法.核心的CSS代码如下(数值不固定): ...

  4. Lotus开发之Lotus Notes中域的验证

    一:介绍       Lotus中的域主要有以下的类型:文本,日期/时间,对话框列表,复选框,单选按钮,RTF等等.Lotus中域的验证方式有很多种公式,lotusscript,javascript等 ...

  5. [算法导论]强连通分量 @ Python

    class Graph: def __init__(self): self.V = [] class Vertex: def __init__(self, x): self.key = x self. ...

  6. WPF 的datagrid 列名中没有显示下划线是怎么回事?

    引用:http://www.cnblogs.com/sqzhuyi/archive/2011/07/26/sqlserverclient.html#2831497 功能介绍:输入查询语句,显示列表 出 ...

  7. PPTP VPN 一键安装包(图文,OpenVZ适用)[zz]

    [介绍] VPN的英文全称是“Virtual Private Network”,中文名叫“虚拟专用网络”.VPN可以通过特殊加密的通讯协议连接到Internet上,在位于不同地方的两个或多个内部网之间 ...

  8. db2 中文表名和字段

    建库语句 create db test on D: using codeset GBK territory CN 或者 territory cn codeset 和 territory 都是需要指定 ...

  9. Thinkpad X240使用U盘安装Win7系统

    更改BIOS设置 不同电脑的进入BIOS的方式可能不太一样,Thinkpad X240的进入方式是在电脑启动的时候按下回车键,然后按F1进入BIOS. 1. 修改secure boot为Disable ...

  10. dede教程之后台登录是自动跳出解决方法

    有时也不知道什么原因,登录后台时输入全部正确点确认按钮时却会自动跳出.必须输入http://你的域名/dede/login.php才可以登录.通过尝试最终解决了问题,下面分享出来: 1.打开根目录da ...