因為瀏覽器的兼容問題,不同瀏覽器對有些標籤的默認值是不同的,如果沒對 CSS 初始化 往往會出現瀏覽器之間的頁面顯示差異。
當然,初始化樣式會對 SEO 有一定的影響,但魚和熊掌不可兼得,但力求影響最小的情況 下初始化。
最簡單的初始化方法:*{padding:0;margin:0;}(強烈不建議)
淘寶的樣式初始化代碼:
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{ 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;}a{ text-decoration:none;} 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;}