Don't Reset – Soft Reset

Posted By: Mark Aplet 7 Comments May 18, 2010

Summary

Soft Reset (for the lack of a good name) is very similar to many of the already popular resets like Meyer Reset or YUI Reset in that the goal it to level the playing field for web developers. What makes this reset different is that it attempts to hone in and reset only the properties that really need to be reset. Leaving some styling to the browser.

My reason for creating this reset is that I wanted a reset that was not overly bloated with unnecessary resets for html properties that I simply didn't use in my layouts. I also didn't think it's necessary to reset every property on the page when sometimes a simple localized class would be sufficient. For example: some sites may only need the main navigation and sub navigation to be reset. Why reset everything only to build it back up for the main content area?

Goals

reset.css

/* Soft Reset */
body, div, dl, dt, dd, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, textarea, p, blockquote, th, td { margin:0; padding:0; }
table { border-collapse:collapse; border-spacing:0; }
fieldset, img { border:0; }
h1, h2, h3, h4, h5, h6, address, caption { font-style:normal; font-size:100%; font-weight:normal; }
caption, th { text-align:left; }
ol.listreset, .listreset ol, ul.listreset, .listreset ul, .listreset li { margin:0; padding:0; list-style:none; }

Usage

For the most part SoftReset works exactly the same as other resets. The biggest difference is that I abstracted the ordered and unordered list resets into a separate class. Simply apply the class to any list that you need to reset like a navigation for example. Here is an example of how I would use it.

<ul class="navigation listreset">
   <li><a href="">Home</a></li>
   <li><a href="">Blog</a></li>
</ul>

Why Create The .listreset Class?

Reusing classes are performance freebies. If you follow the concepts around Object Oriented CSS (OOCSS) you will already know that abstracting these bits of code can greatly improve your application performance. Where as performing a full reset, to build it up again is a big performance drain. If your using a css framework, chances are, your breaking down and rebuilding lists so often, that this single class can save you hundreds of lines of code on a larger site.

Samples And Testing

The YUI 2 reset already had a very comprehensive HTML test page. I ran my reset against it to see how it did. I also created my own HTML test page with many of the same elements with a few additional ones.

NOTE: Use Firebug to turn the reset off and on.

YUI HTML Test Page | My Test Page

Feedback

Since this is just something I am dabbling with, I would appreciate your feedback on this. Maybe it's a good idea? Maybe It's a stupid idea? I urge you to download a copy of the soft reset css and try it out for yourself. See if it works for you. If you have suggestions for improvements I would like to here them in the comments bellow.

Tags: Code · CSS

7 comments so far ↓

  • 1 Jordan Walker // May 20, 2010 at 6:37 AM
    Interesting article, I had never thought of trimming down the reset.
  • 2 Michael Mior // May 20, 2010 at 9:04 AM
    This looks cool based on your tests. I'm eager to try it out on my own pages. Thanks!
  • 3 Miller Medeiros // May 22, 2010 at 10:28 AM
    I've been using the same technique for a couple years and really recommend it..

    A good idea is to customize the reset based on the tags that you will use on the website (specially if it's for mobile devices) - Eric Meyer's and YUI Reset are way too big.

    Cheers.
  • 4 meysam // May 23, 2010 at 9:29 AM
    very good style
  • 5 Max Bucknell // May 26, 2010 at 3:24 PM
    When I've written it, the reset I will use will be one that resets to sensible values, not straight to zero, so that when I'm writing the html for my site, it doesn't look ugly. Extending Andy Clarke's universal IE6 thing. Adding in a few helpers for me like boilerplate navigation etc.

    It's a project, and school takes up too much of my time :-(
  • 6 Dylan Bauer // May 28, 2010 at 3:03 AM
    I've been using Eric Meyers reset for years, I've never thought of trimming down on it either. A lot of my lists use the default browser styles anyways, and used to find it really tedious rebuilding them.
  • 7 Mark Aplet // May 29, 2010 at 5:43 PM
    Something else, I have been thinking about is removing the p tag from the reset. The defaults are often acceptable except where I need to use a specific typographic styling. Any thoughts on that? Pros/Cons outside of the obvious typography grids?

Leave a Comment

Leave this field empty:

Theme Design By Mark Aplet

Super Powered by Mango Blog