Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
CSS Mini Reset (vcarrer.com)
51 points by vladocar on May 20, 2010 | hide | past | favorite | 21 comments


Interesting. I never knew I was doing CSS Reset all this time. I add this to the top of most of my CSS files:

    body, html, form {
      margin:0;
      padding:0;
    }
    table {
      border-collapse:collapse;
    }
    a {
      text-decoration:none;
    }
There are a few more rules I add but they depend on each site of course.


I don't use border-collapse (I don't even know what it is)

but i have those also :

  body{
    font-family:verdana;
    font-size:0.8em;
  }

  p,h1,h2,h3,h4{
    margin:0;
    padding:0;
    font-weight:normal;
  }

  ul{
    list-style:none;
    margin:0;
  }


> I don't use border-collapse (I don't even know what it is)

When two borders are stacked together, they will be collapsed into a single border. Only works with tables though.


The ul rules are the only ones I thought were missing from this. Its probably not semantically correct but I use those much more for layout then actual lists these days.


I just add whatever rules I need for my elements. I don't get this all fuss about CSS Resets, and to have them in separate file is not… very wise, let's say.


I think they call it code reuse or Don't Repeat Yourself or something unwise like that.

Dumbzucks!


I call it needless overhead. Seriously, is it that difficult to reset padding and margins only when you need that? Do you really want to have extra HTTP request for some dumb CSS file you can do just fine without? And it has nothing to do with code reuse. Setting a margin, whoa, rocket surgery, no less.


The whole point of a Reset is to have a clean slate to start from. Do you really know, and want to know, every case where IE6/Safari3/ObscureBrowser300 adds a default padding/margin, and how that is different from Opera/Firefox/etc? Same for font families, sizes and styles?

In my opinion, working without a reset of some kind is quite similar to writing C++ classes where data members are not initialized to meaningful values... you just can't trust what you'll end up with.


  Do you really know, and want to know,
  every case where IE6/Safari3/ObscureBrowser300
  adds a default padding/margin, and how that is
  different from Opera/Firefox/etc?
If I care about the margin, I will set it myself anyway. If I don't care, I don't care what the default is and have no need to reset it. As simple as that.


Your choice. I'll just take YUI Reset, combine it with YUI Base, both of which have already been tested thoroughly, and get a reusable foundation for future use.


I have seen this now several times, why don’t those CSS resets use the universal selector?

  * {margin:0;padding:0;}
works fine. You want to reset not only html and body but also your hn and p elements, right? Isn’t that sort of the idea?

That one line is pretty much the only thing I do in the way of CSS reset and it’s tremendously helpful. There will only be margin and padding if I explicitly declare that I want it which in turn helps remove a lot of margin:0; and padding:0; (which before, because of laziness, I often put in just to be safe).


My understanding is that * { anything } is a huge performance hit, especially for rich UI apps.


Ah! That’s why. (Doesn’t matter for what I’m doing, though :)


I prefer to completely reset all default CSS rules and specify them manually. Works great for me, I haven't noticed any drawbacks.

    * {
        background-color: transparent;
        border: none;
        border-spacing: 0;
        font-size: inherit;
        font-weight: inherit;
        font-family: inherit;
        line-height: 1.5em;
        list-style: none inside;
        margin: 0;
        padding: 0;
        text-align: inherit;
        text-decoration: none;
    }


Apart from form inputs getting really messed up, there's a 'massive' speed penalty you incur by using the * selector to reset everything. Where massive probably isn't large enough for most websites, so if it works, carry on :)


That loses all default theming from form inputs though.


What this basically does is what you would do when starting without a CSS reset: Just reset the elements while you're styling them. Elements that you don't use don't get reset.

That's fine of course, but if you make a lot of websites then you really just want a common stylesheet that does everything you might need, and go from there. (I made sencss with that in mind: http://sencss.kilianvalkhof.com )


I use:

   <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.1/build/reset/reset-min.css>


This is the CSS reset I normally use:

    /* reset block elements */
    blockquote, dir, div, dl, form, h1, h2, h3, h4, h5, h6, hr, ol, p, pre, table, ul  { 
	    margin: 0; 
	    padding: 0; 
	    font-size: 1em;
    }


weird, I was expecting Eric Meyer to have a very beautiful CSS website since I learned CSS with his books. I was disapoint.


http://meyerweb.com/eric/css/edge/complexspiral/demo.html

I remember when that was the height of internet awesomeness!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: