html在线转移,HTML5迁移
從HTML4遷移到HTML5
本章講述如何從 HTML4 遷移 到 HTML5.
本章演示了如何把一個(gè)HTML4頁面轉(zhuǎn)換為HTML5頁面,而不破壞原始的內(nèi)容和結(jié)構(gòu)。
你可以采用相同的方法,從XHTML遷移到HTML5.
典型 HTML4
典型 HTML5
一個(gè)典型的 HTML4 頁面
HTML4body {
font-family: Verdana,sans-serif;
font-size: 0.9em;
}
div#header, div#footer {
padding: 10px;
color: white;
background-color: black;
}
div#content {
margin: 5px;
padding: 10px;
background-color: lightgrey;
}
div.article {
margin: 5px;
padding: 10px;
background-color: white;
}
div#menu ul {
padding: 0;
}
div#menu ul li {
display: inline;
margin: 5px;
}
Monday Times
- News
- Sports
- Weather
News Section
News Article
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque in porta lorem. Morbi condimentum est nibh, et consectetur tortor feugiat at.
News Article
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque in porta lorem. Morbi condimentum est nibh, et consectetur tortor feugiat at.
© 2016 Monday Times. All rights reserved.
修改為HTML5文檔類型
修改 doctype:
修改為 HTML5 doctype:
修改為 HTML5 編碼
修改 encoding 信息:
修改為 HTML5 encoding:
添加HTML5Shiv
所有現(xiàn)代瀏覽器都支持新的HTML5語義元素. 外,您還可以“教”舊瀏覽器如何處理“未知元素”.
然而,IE8和之前瀏覽器版本,不允許未知元素樣式. 因此,使用HTML5Shiv來實(shí)現(xiàn)
添加 HTML5Shiv:
HTML5Shiv 盡在 HTML5 瀏覽器支持
修改HTML5語義元素
現(xiàn)存的CSS包括 元素的 id和class樣式
body {
font-family: Verdana,sans-serif;
font-size: 0.9em;
}
div#header, div#footer {
padding: 10px;
color: white;
background-color: black;
}
div#content {
margin: 5px;
padding: 10px;
background-color: lightgrey;
}
div.article {
margin: 5px;
padding: 10px;
background-color: white;
}
div#menu ul {
padding: 0;
}
div#menu ul li {
display: inline;
margin: 5px;
}
使用HTML5的語義元素替換CSS樣式
body {
font-family: Verdana,sans-serif;
font-size: 0.9em;
}
header, footer {
padding: 10px;
color: white;
background-color: black;
}
section {
margin: 5px;
padding: 10px;
background-color: lightgrey;
}
article {
margin: 5px;
padding: 10px;
background-color: white;
}
nav ul {
padding: 0;
}
nav ul li {
display: inline;
margin: 5px;
}
最后,修改元素為HTML5語義元素:
Monday Times
- News
- Sports
- Weather
News Section
News Article
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque in porta lorem. Morbi condimentum est nibh, et consectetur tortor feugiat at.
News Article
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque in porta lorem. Morbi condimentum est nibh, et consectetur tortor feugiat at.
? 2014 Monday Times. All rights reserved.
和
之間的區(qū)別這是一個(gè)令人困惑的(缺乏)在HTML5標(biāo)準(zhǔn)差, 在 和
之間.在HTML5標(biāo)準(zhǔn)里面, 元素被定義為相關(guān)元素的塊.
元素被定義為一個(gè)完整的、獨(dú)立的相關(guān)元素塊.
元素定義為子元素的塊.如何解釋?
在上面的例子中, 我們使用 作為相關(guān)的容器.
但是, 我們也使用作為其他article的容器.
以下是一些不同的例子:
在 里面:
Famous Cities
London
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
Paris
Paris is the capital and most populous city of France.
Tokyo
Tokyo is the capital of Japan, the center of the Greater Tokyo Area,
and the most populous metropolitan area in the world.
在 里面:Famous Cities
London
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
Paris
Paris is the capital and most populous city of France.
Tokyo
Tokyo is the capital of Japan, the center of the Greater Tokyo Area,
and the most populous metropolitan area in the world.
在里面 , 在 里面:Famous Cities
London
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
Paris
Paris is the capital and most populous city of France.
Tokyo
Tokyo is the capital of Japan, the center of the Greater Tokyo Area,
and the most populous metropolitan area in the world.
Famous Countries
England
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
France
Paris is the capital and most populous city of France.
Japan
Tokyo is the capital of Japan, the center of the Greater Tokyo Area,
and the most populous metropolitan area in the world.
總結(jié)
以上是生活随笔為你收集整理的html在线转移,HTML5迁移的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华为鸿蒙os公测需要多久,华为系统公测到
- 下一篇: html 正则表达式 中文,正则表达式的