1、为什么初始化样式?
因为各种浏览器存在不同的兼容性问题,不同浏览器有些标签的默认值是不同的,如果没有CSS初始化往往会出现浏览器之间的页面显示差异。
初始化样式会对SEO有一定的影响,因为网页加载速度利用合并多个CSS样式,网页进行重新渲染,会影响页面加载速度,对于移动站点与电商SEO,这具有至关重要的作用。总的来说,CSS样式在SEO中最重要的作用,就是平衡链接在内容页面与HTML的展示位置,它严重影响蜘蛛抓取的频率,以及传递的权重。但力求影响最小的情况下初始化。
2、常用的通配符初始化样式问题
清除内外边距直接用*{margin:0;padding:0;},一般在开发中,不建议这么写,因为会及其消耗网站的响应性能,降低网站加载速度。
3、常用标签的默认样式
body标签:默认margin:8px;
dl标签,p标签:默认margin-top:1em;margin-bottom:1em;
dd标签:默认margin-left:40px;
ul、ol标签:默认margin-top:1em;margin-bottom:1em;padding-left:40px;
h1标签~h6标签:默认margin-top:0.67em;margin-bottom:0.67em;
form标签:默认margin-top:0em;
fieldset标签:默认margin-left:2px;margin-right:2px;padding:0.35em 0.75em 0.625em;
legend标签:默认padding-left:2px;padding-right:2px;
input标签:默认padding:1px 0px;
textarea标签:默认padding:2px;
button标签:默认padding:1px 6px;
hr标签:默认margin-top:0.5em;margin-bottom:0.5em;\
pre标签:默认margin:1em 0px 1em;
4、常用的网页初始化标签样式
body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td ,select{ margin:0; padding:0; }
body, button, input, select, textarea { font:12px/1.5tahoma, arial, \5b8b\4f53; }
h1, h2, h3, h4, h5, h6{ font-size:100%; }
address, cite, dfn, em, var { font-style:normal; }
code, kbd, pre, samp { font-family:couriernew, courier, monospace; }
small{ font-size:12px; }
ul, ol { list-style:none; } 默认为initial;
a { text-decoration:none; } 默认下划线为underline,color为#00e;
a:hover { text-decoration:underline; }
sup { vertical-align:text-top; }
sub{ vertical-align:text-bottom; }
legend { color:#000; }
fieldset, img { border:0; }
button, input, select, textarea { font-size:100%; }
table { border-collapse:collapse; border-spacing:0; }
5、初始化图片标签
img{
border:none;
verticla-align:middle;
}
border:ie默认有边框;verticla-align:默认是baseline(基线)