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

Writing a CSS reset

From: Managing CSS in Dreamweaver

Video: Writing a CSS reset

One of the most common problems that designers face when writing their styles is failing to account for the default margins and padding inherent in most browsers. Every browser has a default style sheet that assigns properties to common elements like paragraphs and headings, and every browser's style sheet is just a little bit different from the others. It can be extremely frustrating to try to track down why you have that little bit of extra space between paragraphs in your styles, when in fact, the problem was with the default styling from a browser, not your style sheet.

Writing a CSS reset

One of the most common problems that designers face when writing their styles is failing to account for the default margins and padding inherent in most browsers. Every browser has a default style sheet that assigns properties to common elements like paragraphs and headings, and every browser's style sheet is just a little bit different from the others. It can be extremely frustrating to try to track down why you have that little bit of extra space between paragraphs in your styles, when in fact, the problem was with the default styling from a browser, not your style sheet.

Now, to deal with this, and to make it a little bit easier to have pages look consistent across multiple browsers, many designers use a CSS Reset. A CSS Reset is typically a grouped selector that simply resets the values like padding and margin to 0, stripping off all the default values found in most browsers. So let's go ahead and build one. Again, this is a page with no styling whatsoever. You can see the main.css is empty, other than all the headers and the sections that we have here. So if I preview this page in my browser currently, I still see styling.

So even though my CSS file doesn't have a single bit of styling in it, my headings are of certain size. They are of certain color, there is a certain amount of space between them, and the paragraphs. There is a certain amount of space between all my lists and the list items, things like that. So we've got a lot of styling going on here, even though we had absolutely nothing to do with it. So all these properties are currently being applied from, in this case Firefox default margins and paddings, and styling. If you have another browser open, you will be seeing that browser's default styling. So I am going to go ahead and close this, and we're going to go back and write our selector.

Now, sometimes it's a little bit easier just to write certain selectors by hand, and this is one of those. So I'm going to select my main.css and switch to Code view. What I want to do is I want to scroll down, and this is another reason why we are doing it by hand, I want to find this limited-scale reset content feature because that is where this goes. So I am going to place my cursor just inside that area, and I am just going to start by using some of the elements that I know I am going to be using in my page and some of the elements that I know I am going to be using on my page that I am going to want to style myself.

So I am going to type in h1, h2, h3, h4, h5, h6. Now, by the way, I am going to pause here for just a minute. Most of you probably already know this, but if you don't, the comma is used to group selectors together. So essentially, we're saying apply the same styling to the h1, the h2, the h3, so forth and so on. They don't all have to be element selectors. You could put descendent selectors, class selectors, you can group any selector types together. It does not matter. So right after h6 I am going to hit comma again.

I'll do p, address, blockquote, div, ul, li. Now, you will note that I am not using a lot of elements here. I know you're probably tired of typing, but trust me there is a lot more that you can strip this out of. These are just elements that I know I am going to be using and I know I am going to style separately in my style sheet. So I am going to go ahead and open up a curly brace. Hit Return or Enter to get down the next line, and I am going to type in margin: 0; padding: 0; and note that I am using code hinting and code completion to help really speed that process up.

So when I am done typing in margin: 0 and padding: 0, I'll just close my curly brace, and there is my limited-scale reset. Now, you'll note here that I'm only doing the margin and the padding. I am not doing any typography. I am not doing any line height. I am not doing any color resets here. Some resets are extremely detailed. They will tackle almost every single element you could possibly use, and they will reset every single property that you probably set for that. I am not a fan of that. The reason I'm not a fan of that is because you now have to remember to go back in and change all the stuff.

Well, let me show you what I mean. Do a Save All, and preview that in your browser. You see how all the spacing went away? So the font size is still there obviously; the color is still there, that sort of thing, but any type of margins, padding, spacing, gone. If I want to make sure that my spacing has done correctly, now I have to write the styles myself. Well, that's okay because that's what I wanted to do. But I want to make sure that if I have some type of esoteric tag that I almost never use but somehow makes it into my site, I don't want to zero that out, because the answers are, I won't remember that I zeroed it out, and I'll be left with an element that I am like, hmm, why isn't that styling incorrectly? So it's a personal decision as to which elements you want to involve in your reset.

It's also a personal decision as to which properties you want to reset. Do you want to reset font-size? Do you want to reset color? Do you want to reset margins and padding? Whatever default value you want to reset, you can go ahead and pass that into your CSS Reset. Not every CSS Reset is just one selector like ours is, either. Some of them are multiple selectors, because they're stripping off properties that not all tags share. So your CSS Reset might be a lot more complex based on what you are trying to do with it. So as I mentioned, the downside to stripping all of those default margins and padding is that now I am going to have to remember to write those styles, and put it back.

So any elements that I know I am going to style of the course of my style sheets, I'll go ahead and reset those. Now other elements, I will wait and write specific values for them, if necessary. But the browser default value will still be available if the element is used in the page without me realizing it. Like many things in CSS, the use of the Reset usually comes down to personal preference.

Show transcript

This video is part of

Image for Managing CSS in Dreamweaver
Managing CSS in Dreamweaver

41 video lessons · 20865 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 4m 12s
    1. Welcome
      1m 10s
    2. Who is this course for?
      1m 5s
    3. Using the exercise files
      1m 57s
  2. 1h 21m
    1. Controlling CSS in Dreamweaver
      2m 34s
    2. Style formatting options
      4m 59s
    3. Controlling shorthand notation
      6m 9s
    4. Building a style-focused workspace
      6m 10s
    5. CSS Styles panel overview
      8m 18s
    6. The Properties Inspector
      6m 39s
    7. Creating styles visually
      11m 32s
    8. Hand-coding styles
      8m 15s
    9. Code hinting and code completion
      7m 11s
    10. Modifying styles visually
      5m 24s
    11. Using the Code Navigator
      4m 47s
    12. Using CSS Inspect
      9m 52s
  3. 1h 14m
    1. Structuring style sheets
      4m 52s
    2. Writing a style header
      2m 40s
    3. Building a color guide
      6m 5s
    4. Writing a style sheet table of contents
      8m 46s
    5. Creating sections for styles
      9m 10s
    6. Using the CSS Styles panel to organize styles
      10m 29s
    7. Resolving conflicts
      7m 3s
    8. Organizing style properties
      9m 33s
    9. Writing a CSS reset
      5m 20s
    10. Writing global classes
      3m 57s
    11. Creating a style guide
      6m 6s
  4. 1h 7m
    1. Preparing custom starter pages
      11m 32s
    2. Building custom starter pages
      10m 8s
    3. Working with code snippets
      9m 54s
    4. Writing snippets
      11m 30s
    5. Importing snippets
      6m 3s
    6. Understanding snippets libraries
      8m 11s
    7. Building a CSS framework using snippets libraries
      10m 36s
  5. 52m 15s
    1. Writing a print style sheet
      10m 3s
    2. Creating print-specific styles
      10m 45s
    3. Preparing modular styles
      4m 33s
    4. Creating modular style sheets
      7m 9s
    5. Checking browser compatibility
      6m 25s
    6. Using conditional comments for Internet Explorer
      6m 58s
    7. Optimizing CSS with Dreamweaver
      6m 22s
  6. 38s
    1. Goodbye
      38s

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 Managing CSS in Dreamweaver.

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.