1、新的DOCTYPE和字符集

HTML5的一项准则就是化繁为简,Web页面的DOCTYPE被极大的简化。

<!DOCTYPE html>

同时字符集声明也被简化了:

<meta charset="utf-8">

2、新元素和旧元素

HTML5引入了很多新的标签,根据内容和类型的不同,被分为7大类。

3、语义化标签

语义化标签可以简化HTML页面设计,并且将来搜索引擎在抓取和索引网页的时候,也会利用这些元素的优势。

HTML5的宗旨之一就是存在即合理。Google分析了上百万的页面,发现DIV标签的通用ID名称重复量很大。例如,很多开发人员喜欢使用DIV id="footer"来标记页脚内容,

所以HTML5 引入了一组新的片段类元素。

4、HTML5代码样例

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>HTML5</title>
<link rel="stylesheet" href="html5.css">
</head> <body>
<header>
<h1>My first web</h1>
<h2>learn html5</h2>
<h4>HTML5 Rocks!</h4>
</header> <div id="container">
<nav>
<h3>导 航 链 接</h3>
<a href="http://www.baidu.com">百 度</a>
<a href="http://www.google.com">谷 歌</a>
<a href="http://www.sina.com">新 浪</a>
</nav> <section>
<article>
<header>
<h1>什么是 HTML5</h1>
</header>
<p>  HTML5 将成为 HTML、XHTML 以及 HTML DOM 的新标准。</p>
<p>  HTML 的上一个版本诞生于 1999 年。自从那以后,Web 世界已经经历了巨变。</p>
<p>  HTML5 仍处于完善之中。然而,大部分现代浏览器已经具备了某些 HTML5 支持。</p>
<footer>
<h2>what is html5</h2>
</footer>
</article> <article>
<header>
<h1>HTML5 新特性</h1>
</header>
<ul>
<li>用于绘画的 canvas 元素
<li>用于媒介回放的 video 和 audio 元素
<li>对本地离线存储的更好的支持
<li>新的特殊内容元素,比如 article、footer、header、nav、section
<li>新的表单控件,比如 calendar、date、time、email、url、search
</ul>
<footer>
<h2>new feature of html5</h2>
</footer>
</article>
</section> <aside>
<div>
SEARCH:<input type="text"></input>
<button>Go</button>
</div> <p>HTML5:Lorem ipsum dolor HTML5 nunc ant nunquam sit amet, consectetur adipiscing
elit. Vivamus at est eros, vel frinailla urna.</p>
<p>Per inceptos himenaeos. Quisque feugiat, justo at vehicula
pellentesque, turpis lorem dictum nunc.</p>
</aside>
<footer>
<h2>Copyright:Caijinping</h2>
</footer>
</div>
</body> </html>

效果演示:

5、CSS设置内容样式

<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<title>HTML5</title>
<link rel="stylesheet" href="html5.css">
<style>
body{
background-color:#CCCCCC;
font-family:Geneva,Arial,Helvetica,sans-serif;
margin:0px auto;
border:solid;
border-color:#FFFFFF;
}
header{
background-color:#F47D31;
display:block;
color:#FFFFFF;
text-align:center;
}
header h2{
margin:0px;
color:white;
}
h1{
font-size:72px;
margin:0px;
}
h2{
font-size:24px;
margin:0px;
text-align:center;
color:#F47D31;
}
h3{
font-size:18px;
margin:0px;
text-align:center;
color:#F47D31;
}
h4{
color:#F47D31;
background-color:#fff;
-webkit-box-shadow:2px 2px 20px #888;
-webkit-transform:rotate(-45deg);
-moz-box-shadow:2px 2px 20px #888;
-moz-transform:rotate(-45deg);
position:absolute;
padding:0px 120px;
top:40px;
left:-110px;
text-align:center;
}
nav{
display:block;
width:10%;
float:left;
text-align:center;
}
nav a:link,nav a:visited{
display:block;
border-bottom:3px solid #fff;
padding:10px;
text-decoration:none;
font-weight:bold;
margin:5px;
}
nav a:hover{
color:white;
background-color:#F47D31;
}
nav h3{
margin:15px;
color:white;
}
#container{
background-color:#888;
}
section{
display:block;
width:65%;
float:left;
}
article{
background-color:#eee;
display:block;
margin:10px;
padding:10px;
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px;
-webkit-box-shadow:2px 2px 20px #aaa;
-webkit-transform:rotate(0deg);
-moz-box-shadow:2px 2px 20px #aaa;
-moz-transform:rotate(0deg);
}
article header{
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px;
padding:5px;
}
article footer{
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px;
padding:5px;
}
article h1{
font-size:18px;
}
aside{
display:block;
width:25%;
float:left;
}
aside div{
margin:15px;
color:white;
float:left;
}
aside p{
margin:15px;
color:white;
font-weight:bold;
font-style:italic;
}
footer{
clear:both;
display:block;
background-color:#F47D31;
color:#FFFFFF;
text-align:center;
padding:15px;
float:bottom;
}
footer h2{
font-size:14px;
color:white;
}
a{
color:#F47D31;
}
a:hover{
text-decoration:underline;
}
li{
padding:10px;
}
</style>
</head> <body>
<header>
<h1>My first web</h1>
<h2>learn html5</h2>
<h4>HTML5 Rocks!</h4>
</header> <div id="container">
<nav>
<h3>导 航 链 接</h3>
<a href="http://www.baidu.com">百 度</a>
<a href="http://www.google.com">谷 歌</a>
<a href="http://www.sina.com">新 浪</a>
</nav> <section>
<article>
<header>
<h1>什么是 HTML5</h1>
</header>
<p>  HTML5 将成为 HTML、XHTML 以及 HTML DOM 的新标准。</p>
<p>  HTML 的上一个版本诞生于 1999 年。自从那以后,Web 世界已经经历了巨变。</p>
<p>  HTML5 仍处于完善之中。然而,大部分现代浏览器已经具备了某些 HTML5 支持。</p>
<footer>
<h2>what is html5</h2>
</footer>
</article> <article>
<header>
<h1>HTML5 新特性</h1>
</header>
<ul>
<li>用于绘画的 canvas 元素
<li>用于媒介回放的 video 和 audio 元素
<li>对本地离线存储的更好的支持
<li>新的特殊内容元素,比如 article、footer、header、nav、section
<li>新的表单控件,比如 calendar、date、time、email、url、search
</ul>
<footer>
<h2>new feature of html5</h2>
</footer>
</article>
</section> <aside>
<div>
SEARCH:<input type="text"></input>
<button>Go</button>
</div> <p>HTML5:Lorem ipsum dolor HTML5 nunc ant nunquam sit amet, consectetur adipiscing
elit. Vivamus at est eros, vel frinailla urna.</p>
<p>Per inceptos himenaeos. Quisque feugiat, justo at vehicula
pellentesque, turpis lorem dictum nunc.</p>
</aside>
<footer>
<h2>Copyright:Caijinping</h2>
</footer>
</div>
</body> </html>

效果演示:

HTML5新特性之CSS+HTML5实例的更多相关文章

  1. 前端进阶系列(三):HTML5新特性

    HTML5 是对 HTML 标准的第五次修订.其主要的目标是将互联网语义化,以便更好地被人类和机器阅读,并同时提供更好地支持各种媒体的嵌入.HTML5 的语法是向后兼容的.现在国内普遍说的 H5 是包 ...

  2. html5新特性contenteditable 属性更容易实现动态表单

    介绍html5新特性的一个属性:contenteditable 作用域全局.所有的块标签都可以,例如:span.p.div.td等标签.但是,不可以作用域<br/>类型的标签. conte ...

  3. 转: HTML5新特性之Mutation Observer

    转: HTML5新特性之Mutation Observer Mutation Observer是什么 Mutation Observer(变动观察器)是监视DOM变动的接口.当DOM对象树发生任何变动 ...

  4. html5新特性与用法大全了解一下

    有好多小伙伴私聊我问我html5新特性 和用法,下面我给大家具体介绍一下html5都新加了哪些新特性,下面我给大家总结一下. 1)新的语义标签 footer header 等等2)增强型表单 表单2. ...

  5. 第二季第八天 HTML5新特性

    在函数内部window.a =  a  在全局中就可以拿到这个变量 变量命名.作为函数的参数的时候要详细.调用的时候可以简单点 做全局变量的两个方案 1.绑在标签上data 2.闭包 视频一般都是二进 ...

  6. HTML5新特性 websocket(重点)--多对多聊天室

    一.html5新特性  websocket(重点)--多对多聊天室 HTTP:超文本传输协议 HTTP作用:传输网页中资源(html;css;js;image;video;..) HTTP是浏览器搬运 ...

  7. html5新特性

    这一篇博文不会告诉你怎么去使用html5的新特性,只会给你总结一下新特性------对于好学的人可以把这篇文章当做一个目录 对于初接触的人来说是一个导向 对于已经接触过的人来说是一个检测你掌握程度的检 ...

  8. HTML5新特性:FileReader 和 FormData

    连接在这里: HTML5新特性:FileReader 和 FormData

  9. web全栈架构师[笔记] — 03 html5新特性

    HTML5新特性 一.geolocation PC端 精度比较低 通过IP库定位 移动端 通过GPS window.navigator.geolocation 单次 getCurrentPositio ...

随机推荐

  1. css中em与px

    Px是绝对定位   em是相对定位 1. em的值并不是固定的: 2. em会继承父级元素的字体大小. em应用: 1. body选择器中声明Font-size=62.5%:(注:在ie中把body选 ...

  2. 用CSS3绘制图形

    参考资料:http://blog.csdn.net/fense_520/article/details/37892507 本文非转载,为个人原创,转载请先联系博主,谢谢~ 准备: <!DOCTY ...

  3. 对手机SD卡的一些操作

    首先要导入外包 log4j-1.2.16.jar 代码如下: package com.car273.util; import java.io.BufferedReader; import java.i ...

  4. ICON图标文件解析

    icon是一种图标格式,用于系统图标.软件图标等,这种图标扩展名为*.icon.*.ico.常见的软件或windows桌面上的那些图标一般都是ICON格式的. ICON文件格式比较简单,包含文件头段. ...

  5. Linux编程---套接字

    网络相关的东西差点儿都是建立在套接字之上.所以这个内容对于程序猿来说还是蛮重要的啊. 事实上套接字也就是一个特殊的设备文件而已,我始终不能明确为什么要叫套接字.这么个奇怪的名字.只是还是就这样算了吧. ...

  6. 利用虚拟光驱实现 将WINDOWS文件供虚拟机中的UBUNTU共享

    此方法只能实现(至少目前我发现只能这样)将文件传递给虚拟机中的ubuntu 中,供ubuntu系统阅读,拷贝等,但不能将ubuntu中的数据传递给windows. 即:每次更新windows的数据到u ...

  7. Image editing techniques and algorithms using Qt

    费了好半天劲先翻译这一点.还有好多地方不明白.先弄明白这一点.继续以后的翻译. 这一篇文章我们将讨论不同的技术和算法来修改图像使用Qt.但是在这之前我们继续你必须知道一些原则处理图片. 这里主要有两种 ...

  8. QT 信号与槽 QT简单加法器的实现

    信号与槽 背景: 面向过程 模块之间低耦合设计(高内聚). 函数调用: 直接调用 回调调用(低耦合) 面向对象 模块之间低耦合设计(高内聚) 对象调用 直接调用 接口调用 QT: 信号与槽解决问题: ...

  9. c/c++中与字符串处理相关的函数

    void *memccpy (void *dest, const void *src, int c, size_t n); 从src所指向的对象复制n个字符到dest所指向的对象中.如果复制过程中遇到 ...

  10. Android学习笔记_点九绘图与软键盘和事件传递

    最近项目里遇到的几个小问题,以前只是用吗没有深入看过,现在总结到一起,防止以后这种小问题占用太多时间.还是通过网上别人总结的很多博客学习了,挑选出最易懂明了的. 还有leader很小的问题都不放过,亲 ...