暫時先這麼多,後面遇到再補充
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<title>Page title</title>
<link href="//cdn.bootcss.com/normalize/5.0.0/normalize.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="http://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<noscript>
<style>
body * { display:none; }
.noscript { display:block; width: 50%; height: 20%; text-align: center; }
.absolute-center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
</style>
</noscript>
</head>
<body>
<noscript class="absolute-center noscript">你的瀏覽器不支持Javascript或關閉了Javascript,暫時無法瀏覽</noscript>
</body>
</html>
h5
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width" name="viewport" />
<meta content="telephone=no" name="format-detection" />
<script type="text/javascript">
var debounce = function(idle, action){
var last
return function(){
var ctx = this, args = arguments
clearTimeout(last)
last = setTimeout(function(){
action.apply(ctx, args)
}, idle)
}
};
(function() {
// deicePixelRatio :設備像素
var scale = 1 / devicePixelRatio;
//設置meta 壓縮界面 模擬設備的高分辨率
document.querySelector('meta[name="viewport"]').setAttribute('content', 'initial-scale=' + scale + ', maximum-scale=' + scale + ', minimum-scale=' + scale + ', user-scalable=no');
//debounce 爲節流函數,自己實現。或者引入underscoure即可。
var reSize = debounce(function() {
var deviceWidth = document.documentElement.clientWidth > 1300 ? 1300 : document.documentElement.clientWidth;
//按照640像素下字體爲100px的標準來,得到一個字體縮放比例值 6.4
document.documentElement.style.fontSize = (deviceWidth / 6.4) + 'px';
}, 50);
window.onresize = reSize;
})();
</script>
<title>Page title</title>
<link href="//cdn.bootcss.com/normalize/5.0.0/normalize.css" rel="stylesheet">
<noscript>
<style>
body * { display:none; }
.noscript { display:block; width: 50%; height: 20%; text-align: center; }
.absolute-center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
</style>
</noscript>
</head>
<body>
<noscript class="absolute-center noscript">你的瀏覽器不支持Javascript或關閉了Javascript,暫時無法瀏覽</noscript>
</body>
</html>
1 . HTML5 doctype
爲每個 HTML 頁面的第一行添加標準模式(standard mode)的聲明,這樣能夠確保在每個瀏覽器中擁有一致的展現。
<!DOCTYPE html>
<html>
<head>
</head>
</html>
2 . lang=”zh-CN”
強烈建議爲 html 根元素指定 lang 屬性,從而爲文檔設置正確的語言。這將有助於語音合成工具確定其所應該採用的發音,有助於翻譯工具確定其翻譯時所應遵守的規則等等。
<html lang="zh-CN">
<!-- ... -->
</html>
3 . IE 兼容模式
IE 支持通過特定的 標籤來確定繪製當前頁面所應該採用的 IE 版本。除非有強烈的特殊需求,否則最好是設置爲 edge mode,從而通知 IE 採用其所支持的最新的模式。
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
4 . 字符編碼
通過明確聲明字符編碼,能夠確保瀏覽器快速並容易的判斷頁面內容的渲染方式。這樣做的好處是,可以避免在 HTML 中使用字符實體標記(character entity),從而全部與文檔編碼一致(一般採用 UTF-8 編碼)。
<head>
<meta charset="UTF-8">
</head>
5 . <noscript>
元素
當瀏覽器不支持Javascript或者Javascript被禁用時,包含在中的元素纔會顯示出來,否則得話儘管頁面中包含,但其中的內容並不會被顯示。
<html>
<head>
<title></tilte>
<noscript>
<!-- * display:none; -->
<link href="aHaHaHaHaHaHaEvilLaugh.css" rel="stylesheet">
or
<style>
* display:none;
</style>
</noscript>
<script src="example.js" defer="defer" />
</head>
<body>
<noscript>
<p>本頁面需要瀏覽器支持(啓用)Javascript。</p>
</noscript>
</body>
</html>
6 . 註釋
無法識別<script>
標籤的瀏覽器會把標籤的內容顯示到頁面上。
爲了避免瀏覽器這樣做,您應當在註釋標籤中隱藏腳本。老式的(無法識別 <script>
標籤的)瀏覽器會忽略註釋,這樣就不會把標籤的內容寫到頁面上,而新式的瀏覽器則懂得執行這些腳本,即使它們被包圍在註釋標籤中!
<script>
<!--
function displayMsg()
{
alert("Hello World!")
}
//-->
</script>
7 . IE9一下,支持html5和media queries
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="http://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
8 . CDATA
在XHTML(XML)中,CData片段是文檔中的一個特殊區域,這個區域中可以包含不需要解析的任意格式的文本內容。因此,在CData片段中就可以使用任意字符,而且不會導致語法錯誤。
<script>
// <![CDATA[
function compare(a,b){
if(a<b){
alert(“A is less than B”) ;
}else if(a>b){
alert(“A is greater than B”) ;
}else {
alert(“A is equal to B”) ;
}
}
//]]>
</script>
9 . 重置瀏覽器的默認樣式
<link href="//cdn.bootcss.com/normalize/5.0.0/normalize.css" rel="stylesheet">
-
5.
應用的文章連接
http://www.jb51.net/article/35462.htm
http://codeguide.bootcss.com/