Posted by Nicole in Web Development | 41 Comments
Create The Perfect CSS Reset
As every new and experience web developer knows, different browsers process code differently. What may look perfect in Firefox, may be off in Internet Explorer. As annoying and tedious it is to make your website browser compatible, one CSS style sheet can save you a bunch of time from fixing IE6 errors.
These are called CSS Reset sheets and can reduce the time you spend on browser compatibility by resetting CSS elements.
There are many CSS Resets all over the internet that help combat browser problems. Below are a few great CSS Resets:
Instead of focusing on the CSS Reset Frameworks, I want you as the readers to help me in the process of creating a perfect CSS Reset style sheet.
The basic reset
I use Eric Meyer’s Resetting Again as my CSS reset sheet and with his knowledge, his style sheet serves as a start to browser resetting and compatibility. Here we will start with his Resetting Again style sheet:
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,
b, u, i, center,
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-size: 100%;
vertical-align: baseline;
background: transparent;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
/* remember to define focus styles! */
:focus {
outline: 0;
}
/* remember to highlight inserts somehow! */
ins {
text-decoration: none;
}
del {
text-decoration: line-through;
}
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}
Blockquotes are important
His style sheet covers the basics of resetting the browser’s styles, but if you look at the comments on Eric Meyer’s Resetting Again, you will see people are discussing more ways to reset the browsers. If you look at the comment by Paul Chaplin, he commented on the removal of from Reset Reloaded:
blockquote:before, blockquote:after, q:before, q:after
{
content: "";
}
He brought up that Safari will “automatically generate doubled quotes when there are hard-coded quotes in the markup” if not specified properly. On his blog, he has properly coded a fix to the blockquote code:
blockquote, q
{
quotes: none;
}
/*
Safari doesn't support the quotes attribute, so we do this instead.
*/
blockquote:before, blockquote:after, q:before, q:after
{
/*
CSS 2; used to remove quotes in case "none" fails below.
*/
content: "";
/*
CSS 2.1; will remove quotes if supported, and override the above.
User-agents that don't understand "none" should ignore it, and
keep the above value. This is here for future compatibility,
though I'm not 100% convinced that it's a good idea...
*/
content: none;
}
Adding this into Eric Meyer’s reset sheet includes an amazing blockquote reset for Safari, which is becoming a very popular browser. So now our style sheet should look like this:
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,
b, u, i, center,
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-size: 100%;
vertical-align: baseline;
background: transparent;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
/* remember to define focus styles! */
:focus {
outline: 0;
}
/* remember to highlight inserts somehow! */
ins {
text-decoration: none;
}
del {
text-decoration: line-through;
}
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}
blockquote, q
{
quotes: none;
}
/*
Safari doesn't support the quotes attribute, so we do this instead.
*/
blockquote:before, blockquote:after, q:before, q:after
{
/*
CSS 2; used to remove quotes in case "none" fails below.
*/
content: "";
/*
CSS 2.1; will remove quotes if supported, and override the above.
User-agents that don't understand "none" should ignore it, and
keep the above value. This is here for future compatibility,
though I'm not 100% convinced that it's a good idea...
*/
content: none;
}
Combat the IE font sizing bug
If you look further down the page, you will see a comment by Pari that brings up the IE Font Sizing Bug and how the font should be changed to font-size: 100.01% to counter the font sizing bug. Virtually, there is no change between 100% and 100.01%, but to reset fonts, we will add that to our style sheet:
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,
b, u, i, center,
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-size: 100.01%;
vertical-align: baseline;
background: transparent;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
/* remember to define focus styles! */
:focus {
outline: 0;
}
/* remember to highlight inserts somehow! */
ins {
text-decoration: none;
}
del {
text-decoration: line-through;
}
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}
blockquote, q
{
quotes: none;
}
/*
Safari doesn't support the quotes attribute, so we do this instead.
*/
blockquote:before, blockquote:after, q:before, q:after
{
/*
CSS 2; used to remove quotes in case "none" fails below.
*/
content: "";
/*
CSS 2.1; will remove quotes if supported, and override the above.
User-agents that don't understand "none" should ignore it, and
keep the above value. This is here for future compatibility,
though I'm not 100% convinced that it's a good idea...
*/
content: none;
}
End result
Lastly, optional, but two essential techniques to reset forms are adding textarea { overflow: auto; } which automatically disables the scrollbar IE places inside textareas and putting input { border: 0px solid white; margin: 0; padding: 0; } into our style sheet to reset the input and take away the borders that different browsers put. You may take out the last one if you want to keep a simple input for a simple contact form, but if you are planning to style the inputs together or individually; you should put that into the style sheet. Nonetheless, our style sheet ends up looking like this:
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,
b, u, i, center,
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-size: 100.01%;
vertical-align: baseline;
background: transparent;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
/* remember to define focus styles! */
:focus {
outline: 0;
}
/* remember to highlight inserts somehow! */
ins {
text-decoration: none;
}
del {
text-decoration: line-through;
}
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}
blockquote, q
{
quotes: none;
}
/*
Safari doesn't support the quotes attribute, so we do this instead.
*/
blockquote:before, blockquote:after, q:before, q:after
{
/*
CSS 2; used to remove quotes in case "none" fails below.
*/
content: "";
/*
CSS 2.1; will remove quotes if supported, and override the above.
User-agents that don't understand "none" should ignore it, and
keep the above value. This is here for future compatibility,
though I'm not 100% convinced that it's a good idea...
*/
content: none;
}
textarea { overflow: auto; }
input { border: 0px solid white; margin: 0; padding: 0; }
Now, it’s your turn as the reader to discuss this with me and continue the improvement of this reset sheet. Please comment in this post your contribution to this style sheet. Point out the flaws: mine’s, Eric’s and the commentor’s flaws.
Trackbacks/Pingbacks
- links for 2009-04-07 « pabloidz - [...] Open Thread: Create the perfect CSS reset (tags: css) [...]
- 網站製作學習誌 » [Web] 連結分享 - [...] Create the perfect CSS reset [...]
- Create the perfect CSS reset | vitali software - [...] Source: Open Thread: Create the perfect CSS reset « Serene Destiny. [...]
- Creating the Perfect CSS Reset - [...] DIRECT LINK » [...]
- Creating the Perfect CSS Reset | Misr IT Reader - [...] DIRECT LINK » This entry was written by admin and posted on May 25, 2009 at 3:55 am ...
- 今週の管理人Bookmark (5/24-5/31) - ElectronicBrain is eating BreakFast - [...] Open Thread: Create the perfect CSS reset | Serene Destiny [...]




I think you have reached a very well result. Can’t think of a recommendation. Thanks for sharing
to the global reset by eric meyer i usually add a baseline grid which sets the height of block elements to multiples of the body line-height, so i set font-sizes and top/bottom margins for the html elements there.
i also have a typography stylesheet where i set styles for stuff like ins or del (font-style, font-variant, font-weight, text-decoration, border-bottom-styles)
in addition to that i have a different stylesheet for color and background (-images), so i wouldn’t set any color in the global reset, as you did with input { border: 0px solid white }
textarea { overflow: auto; } is a nice addition, i will use that and also the safari fix is nice to have.
in my opinion setting margins and paddings to 0 is enough for a global reset, all the rest has to be handled in extra stylesheets.
thanks for your first post, it evoked thinking.
btw, the submit comment button text beneath the comment form is cut of on ff3/winxp.
Great site this serenedestiny.com and I am really pleased to see you have what I am actually looking for here and this this post is exactly what I am interested in. I shall be pleased to become a regular visitor
This is very up-to-date info. I’ll share it on Digg.
this is a great story. Doing something very similar at this very moment. Added your site to my RSS reader.
FANTASTIC!
that is really cool, i don’t think i’ve heard of that before, resetting css sheets could be really cool if you are working on a lot of different versions.
If you have to do it, you might as well do it right
I rarely comment on blogs but yours I had to stop and say Great Blog!!
Not that I’m impressed a lot, but this is a lot more than I expected when I stumpled upon a link on SU telling that the info here is awesome. Thanks.
Man, that’s great…Thanks for providing such a good info………
Wonderfull…
Incredible site!
Great work, well researched
Hi there, not sure that this is true, but thanks
It is the coolest site,keep so!
I rarely comment on blogs but yours I had to stop and say Great Blog!!
That was nice. Thank you for sharing this one.
I want to say – thank you for this!
I can find many things that I look for here! Thank you very much!
Thanks for the review! I want to say – thank you for this!
I’d just like to thank you for taking the time to create this internet website. It has been extremely helpful
You have a great website. Keep up the good work.
I think that your site is very interesting and nice. Good job !
Hi, good post. I have been wondering about this issue,so thanks for posting. I’ll definitely be coming back to your site.
hey this is a very interesting article!
I really like the layout and colors that you chose for this website! It certainly is incredible!
Hi, good post. I have been wondering about this issue,so thanks for posting. I’ll definitely be coming back to your site.
nice site keep it on
I’m happy I found this, it just made my day!
This site is truly a great resource thanks for all your hard work
Are you from San Diego?
thanks for the catch. I’ll get in there and fix it….
serenedestiny.com – cool!!!!
Are you from San Diego?
You have a great website. Keep up the good work.
Hi! very amused by the website .
Your site looks great! Best of luck to you.
I like your website I will share this with friends
Мне очень понравился текст, так как и у самого трудности с определениями ) Но вот читать трудновато – не отформатировано.
serenedestiny.com – супер!!!!
Thank you. You have helped someone more than you could know.
Very informative and detail…thanks