关于怎样优化HTML以加快下载速度的10个方法

今天在逛codeproject的时候发现了这篇文章:Ten ways to speed up the download time of your web pages:关于怎样优化HTML以加快下载速度的10个方法。

现摘录一下,不代表本人的想法:
1、尽量使用CSS而不是Table来控制页面外观;
2、不要使用图片来显示特别的文字,请使用CSS;
3、使用CSS来定义背景图片;
3、使用连贯性文本,如:
不要:

< class ="text" > This is a sentence </ p >
< class ="text" > This is another sentence </ p >
< class ="text" > This is yet another sentence </ p >
< class ="text" > This is one more sentence </ p >

而要:

< div  class ="text" >
< p > This is a sentence </ p >
< p > This is another sentence </ p >
< p > This is yet another sentence </ p >
< p > This is one more sentence </ p >
</ div >

5、使用简化CSS属性,如:
不要:

font-size: 1em;
line-height: 1.5em;
font-weight: bold;
font-style: italic;
font-family: serif

而要:

font: 1em/1.5em bold italic serif


6、最小化空白文字、回车和注释;
7、资源(图片、CSS等等)使用相对路径;
8、移除不必的meta字段;
9、把CSS、脚本放在外部文件中重用;
10、在非正规HTML标签后面添加“/”结束符号。

你可能感兴趣的:(html)