在此前的文章裡,我們談過 CSS Reset——也就是重設瀏覽器樣式的概念。由於不同瀏覽器的預設樣式往往存在差異,開發時的第一步,通常就是把它們統一,避免元素在不同瀏覽器中呈現不一致的樣子。
下面這段程式碼是 Yahoo 的做法,值得我們參考借鏡:
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,
form,fieldset,input,textarea,p,blockquote,th,td {
padding: 0;
margin: 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
fieldset,img {
border: 0;
}
address,caption,cite,code,dfn,em,strong,th,var {
font-weight: normal;
font-style: normal;
}
ol,ul {
list-style: none;
}
caption,th {
text-align: left;
}
h1,h2,h3,h4,h5,h6 {
font-weight: normal;
font-size: 100%;
}
q:before,q:after {
content:";
}
abbr,acronym { border: 0;
}
不妨參考看看,然後寫出一份更適合自己工作習慣的重置樣式。有任何心得,歡迎留言與大家分享交流。