請始終定義圖像尺寸。這樣做會減少閃爍,因為瀏覽器會在圖像加載之前為圖像預留空間。
img src= html5.gif alt= HTML5 >但是精簡空格更易閱讀,But space-less is easier to read, and groups entities better together:
link rel= stylesheet href= styles.css請勿使用沒有必要的空行和縮進。沒有必要在短的和相關項目之間使用空行,也沒有必要縮進每個元素:
不必要:
body h1 Famous Cities /1 h2 Tokyo /h2 Tokyo is the capital of Japan, the center of the Greater Tokyo Area, and the most populous metropolitan area in the world. It is the seat of the Japanese government and the Imperial Palace, and the home of the Japanese Imperial Family. /body更好:
body h1 Famous Cities /1 h2 Tokyo /h2 Tokyo is the capital of Japan, the center of the Greater Tokyo Area,and the most populous metropolitan area in the world.It is the seat of the Japanese government and the Imperial Palace,and the home of the Japanese Imperial Family. /body表格示例:
table th Name /th th Description /th td A /td td Description of A /td td B /td td Description of B /td /table列表示例:
li LondonA /li li Paris /li li Tokyo /li /ol為了確保恰當?shù)慕忉專约罢_的搜索引擎索引,在文檔中對語言和字符編碼的定義越早越好:
!DOCTYPE html html lang= en-US head meta charset= UTF-8 title HTML5 Syntax and Coding Style /title /head
!-- This is a long comment example. This is a long comment example. This is a long comment example. This is a long comment example. This is a long comment example. This is a long comment example.
長注釋更易觀察,如果它們被縮進兩個空格的話。
如果您從對大小寫不敏感的服務器轉(zhuǎn)到一臺對大小寫敏感的服務器上,這些小錯誤將破壞您的網(wǎng)站。
為了避免這些問題,請始終使用小寫文件名(如果可以的話)。
鄭重聲明:本文版權歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。
新聞熱點
疑難解答