Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Using CSS Resets

From: CSS: Page Layouts

Video: Using CSS Resets

In many cases, how you structure and write your CSS will be determined by your personal design philosophy. Nowhere is this more true than whether or not you're going to use a CSS Reset, and if you do use them, what type of Reset that you are going to use. Now if you are not familiar with them, CSS Reset is a term that's used to describe a collection of styles that are designed to neutralize a portion of a browser's default styling. Now they come in a wide variety, with varying degrees of complexity and functionality. Let's take a look at some of the practical applications for using CSS Resets, and after that I am going to leave you with some additional resources; that way you can learn a little more about them.

Using CSS Resets

In many cases, how you structure and write your CSS will be determined by your personal design philosophy. Nowhere is this more true than whether or not you're going to use a CSS Reset, and if you do use them, what type of Reset that you are going to use. Now if you are not familiar with them, CSS Reset is a term that's used to describe a collection of styles that are designed to neutralize a portion of a browser's default styling. Now they come in a wide variety, with varying degrees of complexity and functionality. Let's take a look at some of the practical applications for using CSS Resets, and after that I am going to leave you with some additional resources; that way you can learn a little more about them.

So I have the Reset.htm file open and you can find that in 01_08 directory, and I am just going to create a simple little CSS Reset. Now just to show you kind of what it is that we are going to be going, if I were preview this page in the browser right now, I can see that there's no styling going on, on my part, but what I am looking at are the browser's default stylings. So all those spacing here, the space between the paragraphs and the headings, all the margins that you are looking at, the font size, that sort of thing, that's all controlled by the browser's default settings.

Now if I'm going to go ahead and style this page, as a general rule, I will probably end up overriding most of those, but in some cases I might not. Sometimes that's helpful, and sometimes it might cause some styling issues, or there might be some conflicts between my styles and the browser's default styles that I didn't anticipate. So the nice thing about a CSS Reset is they just sort of go ahead and give you a baseline to start from that goes ahead and takes away, or sort of zeroes out if you will, a lot of those default styles. Okay so I am going to get back into my code. And one thing that you always want to make sure you do when you write a CSS Reset is place it towards the top of the code.

The idea is that your styles later on will sort of overwrite what you're doing with the CSS Reset. The only thing you are trying to with this is overwrite the browser's default styles. So right underneath the comment that says "add styles here," I am just going to create a very simple CSS Reset. Now I am going to start just by grouping a lot of selectors together, so I am going to start with "html,body, div,h1,h2,h3,P,ul,li" and well that's it for right now.

Now that might seem like a lot but trust me, that is a small CSS Reset. I've seen them with two to three times the number of elements sort of grouped together here. And the only thing we are going to do within the selector is we are going to just going to go margin: zero; padding: zero. Most CSS Resets are a lot more robust than that, throwing in some typographic rules, maybe even doing some things designed to promote cross-browser compatibility. So, those are all sorts of things that you can find in CSS Resets. Okay so if I save this file, go back into my browser and refresh this, you can see the effect that the CSS Reset had on this.

Now that looks terrible, but what it does is it gives us that sort of starting point. I don't have to worry about the default margins and padding of any of these elements conflicting with the styles I am going to write. I am now free to write them without worrying about what the browser's default styling might do in an instance or that I might forget about a browser's default margins in certain locations. All right, now I am going to go back and show you kind of the nice thing that this Reset does for us based on looking at the fully styled page. So I am going to go back into my code, and you'll notice we have a lot of styles here that are already commented out, so I am just going to remove the front part of the comment, which is right there on line 18.

I am going to scroll down to the bottom of styles and get rid of the last part of the comment right there. Now be sure not to delete the closing curly braces from a. Now, let me go ahead and save this. And again I am going to preview this in my browser. Okay, so there is my page, fully styled. It looks nice, not a bad- looking page. But what is it that the CSS Reset is actually doing for us, you know, how can we visualize what that's doing? Well, if I go back into my code and if I comment out the Reset and then preview that in another tab and you can sort of preview what the Reset is actually doing for us.

So I am going to go ahead and comment out the Reset that I just did. So /* for the beginning of the comment */ for the end of the comment and remember, you just want do that right around the CSS Reset that you created. So I will save that, and then I am just going to preview that in a new tab. There we go. And now if I tab back and forth, you can sort of see the difference that we have between one layout and another. Notice one where we don't have the CSS Reset, for example. The default margin on this heading up top is causing the page to be pushed down a little bit, and we have some additional spacing issues throughout that are just slightly different that might make a really big difference in certain layouts. In some layouts you might not notice it at all; in others there might be a really big difference between having or using the Reset or not using it.

Now, I think you can kind of see how beneficial Resets are, but I do want to point out that they're not without their problems. You know one of the reasons that designers are really critical of using CSS Resets is that they are pretty complex. A lot of times they require you to add a lot of weight to your styles that you don't always need. You are not always going to need everything that a lot of these CSS Resets that I am about show you are going to do for you. Now another thing to think about is how much work you actually want the browser to do. Think about what we are asking it. We are asking the browser to go through, strip out all its styling and add a bunch of styling on top of it.

If your styles were already going to overwrite the browser's default styles then your CSS Reset is really just doing a lot of work for nothing. The other thing is, if you do decide to use CSS Resets, don't just go ahead and copy and paste them from somebody else's site, even the ones I am going to show you. Mow Eric Meyer even says in his introduction to his Reset that he hasn't designed it to be used as is, but to be altered and customized to meet the needs of the designer or whatever project you are working on, so really think about them as a starting point and take from them what you need and then strip out the things that you don't need.

Now my own personal approach, if you are wondering about that, to using Resets, it's very minimal. All I really do is I prefer to zero out the default values for elements that I know I am going to be using in that particular site. Now for that reason, I don't have a set Reset that I use for every project. You know, even the ones I am about to show you, there isn't one of those that I just use every time out. I just have a guiding principle of about using a smaller efficient Reset if I need them. Now one of the things that I have provided for you here on the page is a series of links that can take you to different Resets. So I have Yahoo's YUI Reset, Max Design's, Eric Meyer's, HTML5 Reset, and the HTML5 Boilerplate Reset.

Now you can certainly go to each of those, read to the documentation, and learn more about them, figure out what works for your projects and what doesn't, but the site that I really wanted to point out to you was CSS Reset.com, so I am going to go ahead and open that up in a new tab. This site has a lot of information about CSS Resets, what they are, some documentation on them, and then there are links to not only some of the ones that I gave you links to as well, but other ones, so you can either go ahead and just grab the code from them or read the documentation on them as well to figure out whether or not that CSS Reset is right for you.

Okay, so visit those sites, read the documentation for those Resets, go ahead and dig through, explore into the code. You are going to gain a greater appreciation for dealing with browser default styles, what's involved with that, when its appropriate to use Resets, and most importantly, where the use of CSS Resets will fit into your own design philosophy.

Show transcript

This video is part of

Image for CSS: Page Layouts
CSS: Page Layouts

71 video lessons · 41503 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 4m 20s
    1. Welcome
      54s
    2. How to use the exercise files
      3m 26s
  2. 1h 39m
    1. Box model review
      8m 47s
    2. Calculating element dimensions
      11m 11s
    3. Understanding margin collapse
      7m 59s
    4. Calculating em values
      7m 41s
    5. Calculating percentage values
      7m 51s
    6. Normal document flow
      13m 3s
    7. Controlling element display
      8m 53s
    8. Using CSS Resets
      7m 11s
    9. Fixed, fluid, and responsive layouts
      9m 9s
    10. CSS debugging tools
      6m 46s
    11. Using the Firebug Inspector and the WebKit Web Inspector
      11m 5s
  3. 53m 15s
    1. Page design workflow
      3m 6s
    2. Page design tools
      4m 56s
    3. Determining page structure
      7m 18s
    4. Creating image assets
      8m 58s
    5. Creating initial page structure
      7m 3s
    6. Adding meaning with classes and IDs
      5m 23s
    7. Structuring content with HTML5
      6m 6s
    8. Building internal structure
      10m 25s
  4. 1h 36m
    1. Floating elements
      7m 50s
    2. Clearing floats
      7m 28s
    3. Containing floats
      7m 50s
    4. Clearfix technique
      10m 38s
    5. Floating inline elements
      14m 34s
    6. Two-column floated layouts
      8m 17s
    7. Three-column floated layouts
      11m 30s
    8. Column height considerations
      7m 3s
    9. Creating equal-height columns
      10m 42s
    10. Floats: Lab
      5m 25s
    11. Floats: Solution
      5m 21s
  5. 51m 42s
    1. Relative positioning
      7m 59s
    2. Absolute positioning
      8m 59s
    3. Fixed positioning
      4m 23s
    4. Controlling stacking order
      8m 31s
    5. Clipping content
      8m 21s
    6. Controlling content overflow
      5m 38s
    7. Positioning elements: Lab
      3m 59s
    8. Positioning elements: Solution
      3m 52s
  6. 48m 46s
    1. Design considerations for fixed layouts
      3m 28s
    2. Establishing the layout grid
      7m 57s
    3. Defining column spacing
      9m 30s
    4. Applying the grid through CSS
      8m 56s
    5. Creating grid-based assets
      8m 26s
    6. Grid design resources
      6m 22s
    7. Building fixed layouts: Lab
      4m 7s
  7. 44m 35s
    1. Designing for flexible layouts
      2m 30s
    2. Calculating percentage values
      8m 45s
    3. Setting flexible width values
      6m 6s
    4. Making images flexible
      8m 10s
    5. Setting minimum and maximum widths
      7m 24s
    6. Building flexible layouts: Lab
      4m 53s
    7. Building flexible layouts: Solution
      6m 47s
  8. 49m 36s
    1. Responsive layout overview
      3m 49s
    2. Using media queries
      7m 16s
    3. Organizing styles
      8m 39s
    4. Making content responsive
      8m 33s
    5. Mobile design considerations
      7m 32s
    6. Building responsive layouts: Lab
      4m 23s
    7. Building responsive layouts: Solution
      9m 24s
  9. 1h 22m
    1. Creating multi-column text
      6m 36s
    2. Using borders to enhance design
      13m 59s
    3. Rounding corners
      6m 56s
    4. Adding drop shadows
      10m 35s
    5. Working with opacity
      6m 8s
    6. Utilizing the background property
      15m 5s
    7. Working with CSS sprites
      7m 58s
    8. Enhancing page design: Lab
      6m 22s
    9. Enhancing page design: Solution
      8m 38s
  10. 6m 25s
    1. Additional resources
      6m 25s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed CSS: Page Layouts.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.