Index by Christopher Schmitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Resetting Browser-Style Defaults for Elements

Problem

You want to keep browsers from setting values for elements within web pages.

Solution

Use a separate stylesheet that sets all or most of the common HTML elements used in a web document to a value of 0 or that eliminates any auto-generated content, such as the stylesheet created by the Yahoo! Developer Network (see http://developer.yahoo.com/), called YUI Reset CSS:

/*
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.7.0
*/
html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,
pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,
td{margin:0;padding:0;}table{border-collapse:collapse;border-
spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,
var,optgroup{font-style:inherit;font-weight:inherit;}del,
ins{text-decoration:none;}li{list-style:none;}caption,th{text-align:left;}
h1,h2,h3,h4,h5,h6{font-size:100%;font-
weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-
variant:normal;}sup{vertical-align:baseline;}sub{vertical-
align:baseline;}legend{color:#000;}input,button,textarea,select,optgroup,
option{font-family:inherit;font-size:inherit;font-style:inherit;font-
weight:inherit;}input,button,textarea,select{*font-size:100%;}

To apply this reset, apply the code via the link element before the rest of the styles in the web document:

<link rel="stylesheet" type="text/css" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required