來看下常用的標簽列表,后文會一一介紹:
<!DOCTYPE html> <!-- 使用 HTML5 doctype,不區分大小寫 -->
<html lang="zh-cmn-Hans"> <!-- 更加標準的 lang 屬性寫法 http://zhi.hu/XyIa -->
<head>
<meta charset='utf-8'> <!-- 聲明文檔使用的字符編碼 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 優先使用 IE 最新版本和 Chrome -->
<meta name="description" content="不超過150個字符" /> <!-- 頁面描述 -->
<meta name="keywords" content=""/> <!-- 頁面關鍵詞 -->
<meta name="author" content="name, email@gmail.com" /> <!-- 網頁作者 -->
<meta name="robots" content="index,follow" /> <!-- 搜索引擎抓取 -->
<!-- 為移動設備添加 viewport -->
<meta name ="viewport" content ="initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no"> <!-- `width=device-width` 會導致 iPhone 5 添加到主屏后以 WebApp 全屏模式打開頁面時出現黑邊 http://bigc.at/ios-webapp-viewport-meta.orz -->
<!-- iOS 設備 begin -->
<meta name="apple-mobile-web-app-title" content="標題"> <!-- 添加到主屏后的標題(iOS 6 新增) -->
<meta name="apple-mobile-web-app-capable" content="yes" /> <!-- 是否啟用 WebApp 全屏模式 -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <!-- 設置狀態欄的背景顏色,只有在 `"apple-mobile-web-app-capable" content="yes"` 時生效 -->
<meta name="format-detection" content="telephone=no" /> <!-- 禁止數字識自動別為電話號碼 -->
<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL"> <!-- 添加智能 App 廣告條 Smart App Banner(iOS 6+ Safari) -->
<!-- iOS 圖標 begin -->
<link rel="apple-touch-icon-precomposed" href="/apple-touch-icon-57x57-precomposed.png" /> <!-- iPhone 和 iTouch,默認 57x57 像素,必須有 -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/apple-touch-icon-114x114-precomposed.png" /> <!-- Retina iPhone 和 Retina iTouch,114x114 像素,可以沒有,但推薦有 -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/apple-touch-icon-144x144-precomposed.png" /> <!-- Retina iPad,144x144 像素,可以沒有,但推薦有 -->
<!-- iOS 圖標 end -->
<!-- iOS 啟動畫面 begin -->
<link rel="apple-touch-startup-image" sizes="768x1004" href="/splash-screen-768x1004.png" /> <!-- iPad 豎屏 768 x 1004(標準分辨率) -->
<link rel="apple-touch-startup-image" sizes="1536x2008" href="/splash-screen-1536x2008.png" /> <!-- iPad 豎屏 1536x2008(Retina) -->
<link rel="apple-touch-startup-image" sizes="1024x748" href="/Default-Portrait-1024x748.png" /> <!-- iPad 橫屏 1024x748(標準分辨率) -->
<link rel="apple-touch-startup-image" sizes="2048x1496" href="/splash-screen-2048x1496.png" /> <!-- iPad 橫屏 2048x1496(Retina) -->
<link rel="apple-touch-startup-image" href="/splash-screen-320x480.png" /> <!-- iPhone/iPod Touch 豎屏 320x480 (標準分辨率) -->
<link rel="apple-touch-startup-image" sizes="640x960" href="/splash-screen-640x960.png" /> <!-- iPhone/iPod Touch 豎屏 640x960 (Retina) -->
<link rel="apple-touch-startup-image" sizes="640x1136" href="/splash-screen-640x1136.png" /> <!-- iPhone 5/iPod Touch 5 豎屏 640x1136 (Retina) -->
<!-- iOS 啟動畫面 end -->
<!-- iOS 設備 end -->
<meta name="msapplication-TileColor" content="#000"/> <!-- Windows 8 磁貼顏色 -->
<meta name="msapplication-TileImage" content="icon.png"/> <!-- Windows 8 磁貼圖標 -->
<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml" /> <!-- 添加 RSS 訂閱 -->
<link rel="shortcut icon" type="image/ico" href="/favicon.ico" /> <!-- 添加 favicon icon -->
<title>標題</title>
</head>
基本標簽
使用 HTML5 doctype,不區分大小寫。
<!DOCTYPE html> <!-- 使用 HTML5 doctype,不區分大小寫 -->
聲明文檔使用的字符編碼
<meta charset='utf-8'> <!-- 聲明文檔使用的字符編碼 -->
更加標準的 lang 屬性寫法 http://zhi.hu/XyIa
很少情況才需要加地區代碼,通常是為了強調不同地區漢語使用差異,例如:
<p lang="zh-cmn-Hans">
<strong lang="zh-cmn-Hans-CN">菠蘿</strong>和<strong lang="zh-cmn-Hant-TW">鳳梨</strong>其實是同一種水果。只是大陸和臺灣稱謂不同,且新加坡、馬來西亞一帶的稱謂也是不同的,稱之為<strong lang="zh-cmn-Hans-SG">黃梨</strong>。
</p>
優先使用 IE 最新版本和 Chrome
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 優先使用 IE 最新版本和 Chrome -->
SEO 優化
頁面描述
每個網頁都應有一個不超過 150 個字符且能準確反映網頁內容的描述標簽。文檔
<meta name="description" content="不超過150個字符" /> <!-- 頁面描述 -->
頁面關鍵詞
<meta name="keywords" content=""/> <!-- 頁面關鍵詞 -->
定義頁面標題
<title>標題</title>
定義網頁作者
<meta name="author" content="name, email@gmail.com" /> <!-- 網頁作者 -->
定義網頁搜索引擎索引方式,robotterms是一組使用英文逗號「,」分割的值,通常有如下幾種取值:none,noindex,nofollow,all,index和follow。文檔
<meta name="robots" content="index,follow" /> <!-- 搜索引擎抓取 -->
可選標簽
為移動設備添加 viewport
<meta name ="viewport" content ="initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no"> <!-- `width=device-width` 會導致 iPhone 5 添加到主屏后以 WebApp 全屏模式打開頁面時出現黑邊 http://bigc.at/ios-webapp-viewport-meta.orz -->
content 參數:
iOS 設備
添加到主屏后的標題(iOS 6 新增)
<meta name="apple-mobile-web-app-title" content="標題"> <!-- 添加到主屏后的標題(iOS 6 新增) -->
是否啟用 WebApp 全屏模式
<meta name="apple-mobile-web-app-capable" content="yes" /> <!-- 是否啟用 WebApp 全屏模式 -->
設置狀態欄的背景顏色
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <!-- 設置狀態欄的背景顏色,只有在 `"apple-mobile-web-app-capable" content="yes"` 時生效 -->
content 參數:
如果設置為 default 或 black ,網頁內容從狀態欄底部開始。
如果設置為 black-translucent ,網頁內容充滿整個屏幕,頂部會被狀態欄遮擋。
禁止數字識自動別為電話號碼
<meta name="format-detection" content="telephone=no" /> <!-- 禁止數字識自動別為電話號碼 -->
iOS 圖標
rel 參數:
apple-touch-icon 圖片自動處理成圓角和高光等效果。
apple-touch-icon-precomposed 禁止系統自動添加效果,直接顯示設計原圖。
iPhone 和 iTouch,默認 57x57 像素,必須有
<link rel="apple-touch-icon-precomposed" href="/apple-touch-icon-57x57-precomposed.png" /> <!-- iPhone 和 iTouch,默認 57x57 像素,必須有 -->
iPad,72x72 像素,可以沒有,但推薦有
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/apple-touch-icon-72x72-precomposed.png" /> <!-- iPad,72x72 像素,可以沒有,但推薦有 -->
Retina iPhone 和 Retina iTouch,114x114 像素,可以沒有,但推薦有
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/apple-touch-icon-114x114-precomposed.png" /> <!-- Retina iPhone 和 Retina iTouch,114x114 像素,可以沒有,但推薦有 -->
Retina iPad,144x144 像素,可以沒有,但推薦有
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/apple-touch-icon-144x144-precomposed.png" /> <!-- Retina iPad,144x144 像素,可以沒有,但推薦有 -->
iOS 啟動畫面
官方文檔:https://developer.apple.com/library/ios/qa/qa1686/_index.html
參考文章:http://wxd.ctrip.com/blog/2013/09/ios7-hig-24/
iPad 的啟動畫面是不包括狀態欄區域的。
iPad 豎屏 768 x 1004(標準分辨率)
<link rel="apple-touch-startup-image" sizes="768x1004" href="/splash-screen-768x1004.png" /> <!-- iPad 豎屏 768 x 1004(標準分辨率) -->
iPad 豎屏 1536x2008(Retina)
<link rel="apple-touch-startup-image" sizes="1536x2008" href="/splash-screen-1536x2008.png" /> <!-- iPad 豎屏 1536x2008(Retina) -->
iPad 橫屏 1024x748(標準分辨率)
<link rel="apple-touch-startup-image" sizes="1024x748" href="/Default-Portrait-1024x748.png" /> <!-- iPad 橫屏 1024x748(標準分辨率) -->
iPad 橫屏 2048x1496(Retina)
<link rel="apple-touch-startup-image" sizes="2048x1496" href="/splash-screen-2048x1496.png" /> <!-- iPad 橫屏 2048x1496(Retina) -->
iPhone 和 iPod touch 的啟動畫面是包含狀態欄區域的。
iPhone/iPod Touch 豎屏 320x480 (標準分辨率)
<link rel="apple-touch-startup-image" href="/splash-screen-320x480.png" /> <!-- iPhone/iPod Touch 豎屏 320x480 (標準分辨率) -->
iPhone/iPod Touch 豎屏 640x960 (Retina)
<link rel="apple-touch-startup-image" sizes="640x960" href="/splash-screen-640x960.png" /> <!-- iPhone/iPod Touch 豎屏 640x960 (Retina) -->
iPhone 5/iPod Touch 5 豎屏 640x1136 (Retina)
<link rel="apple-touch-startup-image" sizes="640x1136" href="/splash-screen-640x1136.png" /> <!-- iPhone 5/iPod Touch 5 豎屏 640x1136 (Retina) -->
添加智能 App 廣告條 Smart App Banner(iOS 6+ Safari)文檔
<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL"> <!-- 添加智能 App 廣告條 Smart App Banner(iOS 6+ Safari) -->
Android
Android Lollipop 中的 Chrome 39 增加 theme-color meta 標簽,用來控制選項卡顏色。
http://updates.html5rocks.com/2014/11/Support-for-theme-color-in-Chrome-39-for-Android
<meta name="theme-color" content="#db5945">
Windows 8
Windows 8 磁貼顏色
<meta name="msapplication-TileColor" content="#000"/> <!-- Windows 8 磁貼顏色 -->
Windows 8 磁貼圖標
<meta name="msapplication-TileImage" content="icon.png"/> <!-- Windows 8 磁貼圖標 -->
其他
添加 RSS 訂閱
<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss.xml" /> <!-- 添加 RSS 訂閱 -->
添加 favicon icon
<link rel="shortcut icon" type="image/ico" href="/favicon.ico" /> <!-- 添加 favicon icon -->
禁止 Chrome 瀏覽器中自動提示翻譯
例
簡單的 HTML5 文檔:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文檔標題</title>
</head>
<body>
文檔內容......
</body>
</html>
瀏覽器支持
所有主流瀏覽器都支持 <html> 標簽。
標簽定義及使用說明
<html> 標簽告知瀏覽器這是一個 HTML 文檔。
<html> 標簽是 HTML 文檔中最外層的元素。
<html> 標簽是所有其他 HTML 元素(除了 <!DOCTYPE> 標簽)的容器。
HTML 4.01 與 HTML5之間的差異
HTML5 中,增加了一個新屬性:manifest。
HTML 與 XHTML 之間的差異
xmlns 屬性在 XHTML 中是必需的,但在 HTML中不是。
然而,即使 XHTML 文檔中的 <html> 沒有使用 xmlns 屬性,W3C 上的 HTML 驗證器也不會報錯。這是因為 "xmlns=http://www.w3.org/1999/xhtml" 是一個固定值,即使您沒有包含它,此值也會被添加到 <html> 標簽中。
屬性
New :HTML5 中的新屬性。
屬性 | 值 | 描述 |
---|---|---|
manifestNew | URL | 定義一個 URL,在這個 URL 上描述了文檔的緩存信息。 |
xmlns | http://www.w3.org/1999/xhtml | HTML 不支持。只有 XHTML 支持。 規定 XML 的 namespace 屬性(如果您需要您的內容符合 XHTML,則使用這個屬性。)。 |
全局屬性
<html> 標簽支持 HTML 的全局屬性。
如您還有不明白的可以在下面與我留言或是與我探討QQ群308855039,我們一起飛!
TML標簽:
所有內容都在<html></html>標簽之內;
<head></head>內放的是頭部信息,是對頁面的描述,不會直接顯示在頁面中。
<head></head>內的<title></title>中設置的是頁面的標題,<title></title>只能放在<head></head>中;
<body></body>是頁面的主體,大部分顯示內容都定義在這里。
HTML注釋:<!-- -->:
注釋不允許嵌套
html常用標簽:
h標簽(標題),HTML定義了<h1></h1>到<h6></h6>六個h標簽,分別表示不同大小的字體。h1最大,h6最小。
<br/>只是回車,<p>是段落。<p>前后會有比較大的空白,而<br/>則沒有。
<center>居中顯示.
<b>、<strong>粗體,<i>、<em>斜體。<u>下劃線。
<sub>2</sub>下標,如:H<sub>2</sub>O
<sup>2</sup>上標,如:10<sup>2</sup>
<font></font>字體標簽,<font color=“red“ size=“7” face=“隸書”>紅色</font>。color(設置顏色) size(1-7) face(設置字體,設置字體是注意用戶計算機中必須有該字體才能正常顯示)
<hr> color size(厚度) width(長度) align=left/center/right (默認為劇中顯示)
<pre> 預格式化 保持本色;
HTML特殊字符:<(小于號,less than);>(大于號,greater than); (空格)。
超鏈接:<a>標簽的一些常用屬性:href、title、target、name
插入圖片:<img src=“路徑”/>
列表:dl→(定義列表),ul→(無序列表), ol→(有序列表)。
表格:<table>;創建行:<tr>;創建單元格:<td>;表頁眉:<thead>;表主體:<tbody>;表頁腳:<tfoot>;表頭:<th>。
rowspan(合并行)、colspan(合并列)
<input>是主要的表單元素,type的可選值:submit(提交按鈕)、button(普通按鈕)、checkbox表單標簽:(復選框)、file(文件選擇框)、hidden(隱藏字段)、image(圖片按鈕)、password(密碼框)、radio(單選按鈕)、reset(重置按鈕)、text(文本框)。
meta標簽:(包括在head標簽中。主要用來描述頁面自身信息,元信息)
<meta name="keywords" content="C#學習資料,4k8k.net,.net開發,軟件開發,編程自學網"/>
<meta name="description" content="免費更新最新C#相關技術知識,主要包括:.net基礎,網頁前端,三層架構,SQL數據庫..."/>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />網頁編碼
<meta http-equiv="Refresh" content="3" />三秒鐘后刷新此網頁。
<meta http-equiv="Refresh" content="3;url=http://www.4k8k.net" />三秒鐘后重定向到新網頁。
<meta http-equiv="Cache-Control" content="no-cache" /> 禁止瀏覽器緩存頁面。
<meta name="名字" content="值" />關于網頁的描述信息。
<meta http-equiv="名字" content="值" />模擬http響應頭信息。
C#編程自學_做最好的.net自學資料站_更多文章請訪問:http://www.4k8k.net/
歡迎訂閱。
*請認真填寫需求信息,我們會在24小時內與您取得聯系。