Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
CSS: Page Layouts introduces basic layout concepts, gives advice on how to create properly structured HTML based on prototypes and mockups, and goes into critical page layout skills such as floats and positioning. Author James Williamson shows how to combine these techniques to create fixed, fluid, and responsive layouts. Designers are also shown how to enhance their pages through the creative use of CSS techniques like multi-column text, opacity, and the background property. Exercise files are included with this course.
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.
There are currently no FAQs about CSS: Page Layouts.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.