CSS reset 的目的,是降低不同瀏覽器對預設樣式的解讀差異。YUI 與 Eric Meyer 的版本都很常見,但實務上最好依專案需求裁剪,而不是全盤照抄。
/* reset */
html { color: #000; background: #fff; }
body, div, dl, dt, dd, ul, ol, li,
h1, h2, h3, h4, h5, h6,
input, button, textarea, p, blockquote, th, td {
margin: 0;
padding: 0;
}
body {
font: 12px/1 Tahoma, Helvetica, Arial, "微軟正黑體", sans-serif;
}
img { border: none; }
em, strong { font-style: normal; font-weight: normal; }
li { list-style: none; }
table {
border-collapse: collapse;
border-spacing: 0;
}
h1 { font-size: 18px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
h4, h5, h6 { font-size: 100%; }
q:before, q:after { content: ''; }
button, input, select, textarea { font-size: 100%; }
input, button, textarea, select, optgroup, option {
font-family: inherit;
font-size: inherit;
font-style: inherit;
font-weight: inherit;
}
address, cite, dfn, em, var { font-style: normal; }
a { color: #36c; text-decoration: none; }
a:hover { color: #f60; text-decoration: underline; }
這份初始化兼顧了中文環境與表單元素的字體繼承,可作為小型專案的起點。正式使用前,仍應依設計稿與元件需求增減規則。