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. bzoj 1207: [HNOI2004]打鼹鼠

    1207: [HNOI2004]打鼹鼠 Time Limit: 10 Sec  Memory Limit: 162 MB Description 鼹鼠是一种很喜欢挖洞的动物,但每过一定的时间,它还是喜 ...

  2. 转:XBMC源代码分析

    1:整体结构以及编译方法 XBMC(全称是XBOX Media Center)是一个开源的媒体中心软件.XBMC最初为Xbox而开发,可以运行在Linux.OSX.Windows.Android4.0 ...

  3. RPC和NFS

    参考:http://eduunix.ccut.edu.cn/index2/html/linux/OReilly.SUSE.Linux.Jul.2006/059610183X/suselinux-CHP ...

  4. FluentData Mysql分页的一个BUG

    开发环境 FluentData3.0.VS.NET2010.Mysql5.0 问题描述 使用FluentData对一个表(记录数28)进行分页时,突然发现一个诡异的问题,第一页返回10条数据正常,第二 ...

  5. SAP 系统管理内容

    SAP 系统管理内容包含非常广泛,从底层硬件起到各种操作系统及各种系统软件及SAP软件组件等都会涉及到.SAP系统支持主流的IBM AIX.HP UNIX.Windows.Linux平台及Oracle ...

  6. AngularJS 模态对话框

    本文内容 项目结构 运行结果 index.html mymodal.js 参考资料 本文讲解 Angular JS 实现模式对话框.基于 AngularJS v1.5.3.Bootstrap v3.3 ...

  7. PCM音频设备的操作(转)

    对音频设备的操作主要是初始化音频设备以及往音频设备发送 PCM(Pulse Code Modulation)数据.为了方便,本文使用 ALSA(Advanced Linux Sound Archite ...

  8. JAVA利用enum结合testng做数据驱动示例

    数据驱动是做自动化测试中很重要的一部分,数据源的方案也是百花八门了,比如利用外部文件,直接在@DataProvider中写死等等,我们今天介绍一下利用enum来做数据源,先来看一下enum的写法: p ...

  9. 【LeetCode】273. Integer to English Words

    Integer to English Words Convert a non-negative integer to its english words representation. Given i ...

  10. hibernate 映射 多对一

    一对多和上文讲的多对一两种映射关系,其实就是站在相反的角度考虑同样的事情. 一对多和多对一映射原理是一样的,都在多的一端加入一个外键指向一的一端.也就是说,在关系数据库的表中,他们的表及表字段都是一样 ...