


To understand and become familiar with the new semantic elements in HTML5, the best way is to take a classic HTML document as an example, and then enrich it with some fresh nutrients of HTML5. The following is the page we want to transform. The page is very simple and contains only one article.
ApocalypsePage_Original.html, this is a page with a very standardized format, and all styles come from external style sheets.
- html>
- html lang="zh-CN">
- head>
- meta charset="utf-8">
- title>Apocalypse Nowtitle>
- link rel="stylesheet" href="ApocalypsePage_Original.css">
- head>
- body>
- div class="Header">
- h1>How the World Could Endh1>
- p class="Teaser">Scenarios that spell the end of life as we knowp>
- p class="Byline">by Ray N. Carnationp>
- div>
- div class="Content">
- p>span class="LeadIn">Right nowspan>, you're probably feeling pretty good. After all, life in the developed world is comfortablespan class="style1">—span>probably more comfortable than it's been for the average human being throughout all of recorded history.p>
- p>But don't get too smug. There's still plenty of horrific ways it could all fall apart. In this article, you'll learn about a few of our favorites.p>
- h2>Mayan Doomsdayh2>
- p>Skeptics suggest that the Mayan calendar simply rolls to a new 5,126-year era after 2012, and doesn't actually predict a life-ending apocalypse. But given that the long-dead Mayans were wrong about virtually everything else, why should we trust them on this?p>
- h2>Robot Takeoverh2>
- p>Not quite as frightening as a Vampire Takeover or Living-Dead Takeover, a robot rebellion is still a disquieting thought. We are already outnumbered by our technological gadgets, and even Bill Gates fears the day his Japanese robot slave turns him over by the ankles and asks (in a suitably robotic voice) "Who's your daddy now?"p>
- h2>Unexplained Singularityh2>
- p>We don't know how the universe started, so we can't be sure it won't just end, maybe today, and maybe with nothing more exciting than a puff of anti-matter and a slight fizzing noise.p>
- h2>Runaway Climate Changeh2>
- p>Dismissed by some, Al Gore's prophecy of doom may still come true. If it does, we may have to contend with vicious storms, widespread food shortages, and surly air conditioning repairmen.p>
- h2>Global Epidemich2>
- p>Some time in the future, a lethal virus could strike. Predictions differ about the source of the disease, but candidates include monkeys in the African jungle, bioterrorists, birds and pigs with the flu, warriors from the future, an alien race, hospitals that use too many antibiotics, vampires, the CIA, and unwashed brussel sprouts. Whatever the source, it's clearly bad news.p>
- div>
- div class="Footer">
- p class="Disclaimer">These apocalyptic predictions do not reflect the views of the author.p>
- p>
- a href="AboutUs.html">About Usa>
- a href="Disclaimer.html">Disclaimera>
- a href="ContactUs.html">Contact Usa>
- p>
- p>Copyright © 2014p>
- div>
- body>
- html>
在不增加任何 CSS 样式表之前,效果如下:
上面通过三个
这个例子中的样式表很简单,整个页面最大宽度设置为 800 像素,避免文本在宽屏显示器上显示过长。页眉位于一个带有蓝色边框的盒子中,内容区的两侧都增加了内边距,而页脚在整个页面的底部居中。
ApocalypsePage_Original.css样式文件内容如下:
- @charset "utf-8";
- /* CSS Document */
- body{
- /*font-family To use safe fonts, follow the principle of special first and then general,
- First give the font you want, then a safer font,
- Finally ends with sans-serif font*/
- font-family: "Lucida sans Unicode", "Lucida Grande", Geneva, sans-serif;
- max-width: 800px; /*The maximum width does not exceed 800 pixels*/
- }
- /*Title area style at the top of the page*/
- .Header {
- background-color: #7695FE; /*Any color value is acceptable*/
- border: thin #336699 solid; /*all-in-one border attribute*/
- padding: 10px; /* 10 pixel padding, the distance between the border and the content*/
- margin: 10px; /* 10 pixel margin, the distance between the border and surrounding elements*/
- text-align: center; /*Header text is centered*/
- }
- /*Title in headerh1>Style*/
- .Header h1{
- margin: 0px;
- color: white;
- font-size: xx-large; /*Precise control can be done in pixels or em units*/
- }
- /*Header subtitle style*/
- .Header .Teaser{
- margin: 0px;
- font-weight: bold;
- }
- /*Signature line style in header*/
- .Header .Byline{
- font-style: italic;
- font-size: small;
- margin: 0px;
- }
- .Content{
- font-size: medium;
- font-family: Cambria, Cochin, Georgia, "Times New Roman", Times, serif;
- /*Maximum left and right padding*/
- padding-top: 20px;
- padding-right: 50px;
- padding-bottom: 5px;
- padding-left: 50px;
- line-height: 120%; /*The distance between two adjacent text lines*/
- }
- .Content .LeadIn{
- font-weight: bold;
- font-size: large;
- font-variant: small-caps;
- }
- .Content .h2{
- color: #24486C;
- margin-bottom: 2px;
- font-size: medium;
- }
- .Content p{
- margin-top: 0px;
- }
- .Footer{
- text-align: center;
- font-size: x-small;
- }
- .Footer .Disclaimer{
- font-style: italic;
- }
- .Footer p{
- margin: 3px;
- }
In this way, our style sheet has been bent. Now let’s see what the result will be? As shown below:
Use HTML5 to construct the page
To improve this situation with HTML5, replace
In ApocalypsePage_Revised.html, the class attributes of Header and Footer and

html5的div元素默认一行不可以放两个。div是一个块级元素,一个元素会独占一行,两个div默认无法在同一行显示;但可以通过给div元素添加“display:inline;”样式,将其转为行内元素,就可以实现多个div在同一行显示了。

html5中列表和表格的区别:1、表格主要是用于显示数据的,而列表主要是用于给数据进行布局;2、表格是使用table标签配合tr、td、th等标签进行定义的,列表是利用li标签配合ol、ul等标签进行定义的。

固定方法:1、使用header标签定义文档头部内容,并添加“position:fixed;top:0;”样式让其固定不动;2、使用footer标签定义尾部内容,并添加“position: fixed;bottom: 0;”样式让其固定不动。

HTML5中画布标签是“<canvas>”。canvas标签用于图形的绘制,它只是一个矩形的图形容器,绘制图形必须通过脚本(通常是JavaScript)来完成;开发者可利用多种js方法来在canvas中绘制路径、盒、圆、字符以及添加图像等。

html5中不支持的标签有:1、acronym,用于定义首字母缩写,可用abbr替代;2、basefont,可利用css样式替代;3、applet,可用object替代;4、dir,定义目录列表,可用ul替代;5、big,定义大号文本等等。

html5废弃了dir列表标签。dir标签被用来定义目录列表,一般和li标签配合使用,在dir标签对中通过li标签来设置列表项,语法“<dir><li>列表项值</li>...</dir>”。HTML5已经不支持dir,可使用ul标签取代。

3种取消方法:1、给td元素添加“border:none”无边框样式即可,语法“td{border:none}”。2、给td元素添加“border:0”样式,语法“td{border:0;}”,将td边框的宽度设置为0即可。3、给td元素添加“border:transparent”样式,语法“td{border:transparent;}”,将td边框的颜色设置为透明即可。

因为html5不基于SGML(标准通用置标语言),不需要对DTD进行引用,但是需要doctype来规范浏览器的行为,也即按照正常的方式来运行,因此html5只需要写doctype即可。“!DOCTYPE”是一种标准通用标记语言的文档类型声明,用于告诉浏览器编写页面所用的标记的版本。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 Linux new version
SublimeText3 Linux latest version

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
