DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> HTML基礎知識 >> HTML和Xhtml
HTML5 Reset Stylesheet 樣式重置表
編輯:HTML和Xhtml     

這份CSS Reset是在Eric Meyer的經典版本基礎上修改而來,特別針對HTML5調整了相關標籤的初始化樣式,適合在HTML5專案中作為樣式重置的起點。

/*
html5doctor.com Reset Stylesheet
v1.4
2009-07-27
Author: Richard Clark - https://richclarkdesign.com
*/

html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, dialog, figure, footer, header,
hgroup, menu, nav, section,
time, mark, audio, video {
margin:0;
padding:0;
border:0;
outline:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
}
body {
line-height:1;
}

article, aside, dialog, figure, footer, header,
hgroup, nav, section {
display:block;
}

nav ul {
list-style:none;
}

blockquote, q {
quotes:none;
}

blockquote:before, blockquote:after,
q:before, q:after {
content:"";
content:none;
}

a {
margin:0;
padding:0;
border:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
}

ins {
background-color:#ff9;
color:#000;
text-decoration:none;
}

mark {
background-color:#ff9;
color:#000;
font-style:italic;
font-weight:bold;
}

del {
text-decoration: line-through;
}

abbr[title], dfn[title] {
border-bottom:1px dotted #000;
cursor:help;
}

table {
border-collapse:collapse;
border-spacing:0;
}

hr {
display:block;
height:1px;
border:0;
border-top:1px solid #cccccc;
margin:1em 0;
padding:0;
}

input, select {
vertical-align:middle;
}

更新內容重點

這份樣式表移除了HTML5中已不建議使用的標籤樣式(如 <acronym>、<font>、<big>),加入了HTML5新增標籤的樣式,移除了預設的 padding、margin 和 border,並明確指定那些應作為區塊元素顯示的元素其 display 屬性為 block。

使用屬性選擇器

為 <abbr> 和 <dfn> 元素加上屬性選擇器,在這兩個元素帶有 title 屬性時為它們指定樣式,這主要是從可訪問性角度出發的考量。

討論與提醒

值得注意的是,在錨點上設定 outline:0 會有嚴重的可訪問性問題,直接導致鍵盤導航失效。此外,ins 與 mark 在未設定字體顏色時,其實不必額外加上背景顏色。

更多內容可參考 html5doctor.com 上的原文。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved