由于各大浏览器存在兼容性问题,同一个CSS属性在不同浏览器下的表现不一定相同,有经验的前端设计者都会自定义一个重置浏览器样式的CSS文件,在这个文件中定义一些针对不同的浏览器最终表现出一致的代码,大家最熟悉的也许就是* {margin:0 0}了,其实这是最简单的兼容性的代码,一般情况下,仅有这个是不够的,因此笔者收集了几个前端设计网站使用的reset.css代码模板,如果需要你可以复制这些代码保存为reset.css文件,然后引用在所需的html文件中即可。
注意:您可以根据您自己的实际情况去修改代码中选择器的定义,如果确定用不上代码中对某些选择器的定义,可以删除掉
代码01:

body,ul,li,p,h1,h2,h3,h4,h5,h6,img,br,hr,table,tr,td,dl,dt,dd,form { margin: 0; padding: 0; } body { font-family: Arial,"微软雅黑"; font-size: 12px; color: #434343; } .clear { clear: both; font-size: 0px; } ul,li { list-style: none; } img { border: none; } /*一般链接*/ a { text-decoration: none; color: #555; } a: hover { color: #3366ff; }
代码02:

@charset 'utf-8'; html,body,ul,li,ol,dl,dd,dt,p,h1,h2,h3,h4,h5,h6,form,fieldset,legend,img { margin:0; padding:0 } fieldset,img { border:0 } img { display:block } address,caption,cite,code,dfn,th,var { font-style:normal; font-weight:normal } ul,ol { list-style:none } input { padding-top:0; padding-bottom:0; font-family:"SimSun","宋体" } input::-moz-focus-inner{ border:0; padding:0 } select,input{ vertical-align:middle } select,input,textarea{ font-size:12px; margin:0 } input[type="text"],input[type="password"],textarea{ outline-style:none; -webkit-appearance:none } textarea{ resize:none } table{ b order-collapse:collapse }
代码03:来自Eric Meyer网站

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; vertical-align: baseline; } : focus { outline: 0; } body { line-height: 1; color: black; background: white; } ol, ul { list-style: none; } table { border-collapse: separate; border-spacing: 0; } caption, th, td { text-align: left; font-weight: normal; } blockquote: before, blockquote: after, q: before, q: after { content: ""; } blockquote, q { quotes: "" ""; }