CSS Reset

27
CSS GLOBAL RESETS

description

A quick presentation on CSS resets and the benefits vs problems. Also includes a lighter CSS reset option.

Transcript of CSS Reset

Page 1: CSS Reset

CSSGLOBAL RESETS

Page 2: CSS Reset

What isCSS reset?

Page 3: CSS Reset

All browsers have adefault style sheet.

Page 4: CSS Reset

The problem is that these defaultstyle sheets are different in each

browser.

Page 5: CSS Reset

CSS resets aim to remove allbrowser-specific styles, and thenbuild CSS up again from scratch -so that each element will appear

the same in all browsers.

Page 6: CSS Reset

The simplest reset involvesremoving the margin and padding

from all elements using theuniversal selector.

*{

margin: 0;padding: 0;

}

Page 7: CSS Reset

However, this reset canadversely affect some form

elements that should not havetheir margins and padding

removed.

Page 8: CSS Reset

More advanced CSS resets aimto reset almost every aspect of

every element:

• Set margins and padding to zero• Set borders to zero

• Remove visual list styles• Set fonts to a base

• Set font-weight and font-style to normal

Page 9: CSS Reset

Two of the most widely usedCSS resets are:

Eric Meyer Resethttp://meyerweb.com/eric/thoughts/2007/05/0

1/reset-reloaded/

YUI 2: Reset CSShttp://developer.yahoo.com/yui/reset/

Page 10: CSS Reset

Are CSS resetsa good idea?

Page 11: CSS Reset

Some people love CSS resets,and others hate them. There is no

right or wrong, only opinions!

Page 12: CSS Reset

I have three main concernswith CSS resets

Page 13: CSS Reset

Every element that is “zeroed”must then be redefined. This can

cause an increase in CSS filesize.

Page 14: CSS Reset

CSS Resets can present issues ifyou remove the default behaviourfor an element and then forget to

restyle it.

Page 15: CSS Reset

Some resets can be harmful tousers who rely on keyboards for

navigation.

:focus {outline: 0;}

Page 16: CSS Reset

A lighter CSS resetexample

Page 17: CSS Reset

I prefer to use a smaller set ofCSS rules that mean that only

common or problematicelements are reset.

Page 18: CSS Reset

html, body, ul, ol, li, form,fieldset, legend{

margin: 0;padding: 0;

}

1. Remove margin and paddingon some key elements only

Page 19: CSS Reset

h1, h2, h3, h4, h5, h6, p{

margin-top: 0;}

2. Remove top margins onheadings and paragraphs

Page 20: CSS Reset

fieldset, img{

border: 0;}

3. Remove fieldset and imageborders

Page 21: CSS Reset

table{

border-collapse: collapse;border-spacing: 0;

}

4. Set table borders andspacing

Page 22: CSS Reset

caption, th, td{

text-align: left;vertical-align: top;font-weight: normal;

}

5. Set caption, table header andtable data cells

Page 23: CSS Reset

legend{

color: #000;}

6. Apply color to fieldset(to overcome IE color issues)

Page 24: CSS Reset

input, textarea, select{

font-size: 110%;line-height: 1.1;

}

7. Apply font-size and line-heightto input, textarea and select

Page 25: CSS Reset

li{

list-style: none;}

8. Remove list bullets

Page 26: CSS Reset

abbr, acronym{

border-bottom: .1em dotted;cursor: help;

}

9. Apply border-bottom andcursor to abbr and acroynm

Page 27: CSS Reset

sup{

vertical-align: text-top;}

sub{

vertical-align: text-bottom;}

10. Vertical-align sup and sub toavoid line-height issues