New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Start learning with our library of video tutorials taught by experts. Get started

CSS: Page Layouts
Illustration by

Defining column spacing


From:

CSS: Page Layouts

with James Williamson

Video: Defining column spacing

In the previous movie, we began the process of planning a sample two-column fixed layout. We established the target resolution, we decided which unit we were going to base the grid off of, and we defined our grid. So in this movie, we are going to complete that process by using the layout grid to determine how to space our columns and then calculate the element dimensions we will need for our CSS. So I am just going to keep working in the fixed_planning.ai. In the previous movie, if you opened up a layout program and worked with that, then you can just continue doing that. And if you grabbed a piece of sketch paper and you are sketching it out on that, then that's awesome. Just keep doing that.
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

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
CSS: Page Layouts
8h 57m Beginner Feb 07, 2012

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.

Topics include:
  • Reviewing the box model
  • Calculating em and percentage values
  • Controlling how elements display
  • Creating fixed, fluid, and responsive layouts
  • Structuring content with HTML5
  • Floating elements
  • Using relative, absolute, or fixed positioning
  • Defining column spacing
  • Creating grid-based assets and layouts
  • Considering mobile-design-specific issues
  • Working with multi-column text
  • Enhancing page design CSS Sprites
Subjects:
Web Web Design
Software:
CSS
Author:
James Williamson

Defining column spacing

In the previous movie, we began the process of planning a sample two-column fixed layout. We established the target resolution, we decided which unit we were going to base the grid off of, and we defined our grid. So in this movie, we are going to complete that process by using the layout grid to determine how to space our columns and then calculate the element dimensions we will need for our CSS. So I am just going to keep working in the fixed_planning.ai. In the previous movie, if you opened up a layout program and worked with that, then you can just continue doing that. And if you grabbed a piece of sketch paper and you are sketching it out on that, then that's awesome. Just keep doing that.

The first thing I want to focus on is the main column. Now I have already mentioned how this layout is going to be text heavy, so that means that wherever the body copy or the main text is, that's the most important content region on the page, and that is where I typically like to start with my layout. I am going to bring up something that as an art major I tried to avoid for years and years and years, so just give me a moment. Yes, there it is; the calculator. As an art major, I try to stay as far away from math as possible, but it finally caught up to me again. So in terms of spacing columns, we really have to think about readability.

One of the things that you learn if you study typography is that the ideal column width for readability is about 66 characters wide. So if you can make a column that's around 66 characters, that's really the sweet spot, somewhere around in there. Now a character is typically one half of an em, so 0.5 ems. So if our base unit is 16 pixels, that would be the default size of our text, I am going to use 8, I will multiply that by 66, and that gives me 528.

So that is the initial target for my main column, which is going to be on the left-hand side, for our particular layout, 528 pixels. So I am going to go back into my layout program, and I've sort of done myself a little favor here. I have given myself some starter blocks to work with. That's the magic of editing; it's sort of like owning your own cooking show. You can just put something in the oven and you are ready to go with it. So here is my first initial containing block, and I am just going to go ahead and make that 528 pixels wide, and I will just make it 1200 pixels tall to match the rest of our layout.

So let me get control over this thing. I am going to line it up right here with our layout grid, and you can see it just sort of lines up. The thing that I have to think about here is, remember, when we set up our grid, we're basing this off of a 12-column layout. So you can see these heavy gridlines right here are those columns, and there are 12 of them over the course of my layout. That means that my content regions really need to line up with those columns. So what I want to do here then is grab this and just move it out until it lines up with the nearest column, in this case which is right here, and if I'm counting that, that's 1, 2, 3, 4, 5, 6, 7 columns.

If you are thinking to yourself, "Oh, but James, you had it perfect. It was going to be 66 characters long." Remember, number one, that's just an approximation. If you get close to that, that's fine. That's kind of a starting point for us. We have to have everything that we are doing based off of the grid that we are building, so it's okay. Plus, the other thing to remember is that there is going to be some padding inside this and there'll also be some margins between the two columns, so this isn't exactly the width of the content; this is the width of the column, and those are not always the same thing. Now what's really nice about this is since we are doing a two-column layout, the other column is already defined for us now.

So I am just going to take little guy and move him over and then once that's lined up-- let's go ahead and move this over as well to line that up-- now just so I can keep who is who straight, I am going to go ahead and grab that color, so that I have two different color columns. So this is the very beginning of our two-column layout. We have one region that's based off of seven columns of our layout and we have another region on the right- hand side that's based off of five. Oddly enough--and I promise you I did not plan this, this way; it's just kind of worked out when I was doing this.

I was like, huh, the 7:5 ratio is actually part of the golden mean. So if you are familiar with the golden mean as a ratio, 7:5 works out to that. So it should make a very pleasing layout once we are finished with this. Once I have sort of these regions blocked out, now I need to think about what is the actual width of these going to be? So if I click on this particular column, I can see that that column is 560 pixels wide, which means of course that this one is 400 pixels wide. So I am just going to grab this text.

I would normally make notes in my sketchbook, but here we are. So I am going to go 560 overall for this particular column and then this one of course is going to be 400. That's going to give us the overall container block width for these elements, but the container block width and the content width is not the same when you're talking about CSS, because we need to start factoring in spacing, such as padding and margin and things like that. So I am going to work with padding now, and I'm going to grab this little block right here-- yellow is a good color for padding--and I am just going to move this out right here and start working with that.

Again, I want my padding to be based off of my grid. A single gridline is 16 pixels, so I could use that for padding, but in the layout like this, 16 pixels is going to be really close to the edge. You are talking about, like, 1em. So I am going to go out to the very next gridline, and that gives me 32 pixels, and that's what I am going to use for my padding. So I am just going to change the height of this to 1200 to match everybody else, and that's going to shoot it way up there obviously. And then I am going to take it and align with the upper right-hand corner right there. Now I want the same padding on both sides, so I am going to place that over there, and then I have to think about the spacing in between these columns. How are these guys going to be spaced? I really like having a gutter that equals the padding on both sides, so I am going to grab this and then copy it over.

Now, do I want 32 pixels between them, do I want the spacing on this side? Actually, in this case, what I am going to do is I am going to split the difference. I want to put 16 on one side and I am going to put 16 on the other side. What that's going to do for me is it's going to keep that sort of ratio, that nice 7:5 ratio that I have got here going on, and not skew it towards one side or the other. So now I have padding on this side, padding on this side, and then the gutter between the two of them, which can be controlled through margins, it can be controlled through padding, or it can just be controlled through setting the element widths and floating one to the left and one to the right, just like we did in the last chapter.

But what I need to do now and what I will need to know for my CSS is okay, what is this going to do to the overall content widths? So if I grab these measurements, I am just going to come down here and say, okay, this is 32, this is 32, and that's 32. Now the rest of these obviously have to add up to 960 pixels, and we sort of have this overall width. So this 560, I would subtract 32 from it on this side, and I would subtract 16 for this amount of spacing right here.

So, if I bring this down, that's going to give me a total width right here of 512 pixels. I will do the same thing right over here. I have got 400 pixels, and I'm going to have to subtract 48 pixels from that, so that's going to give me a total width here of 352. Again, I am not great at math, but 352 pixels wide. So in essence, what we are doing right now is we're writing our CSS.

We know we have a column on the left- hand side, we know we have a column on the right-hand side, we know the padding values of those columns on the left and right side of the respective columns, we know the width of the columns, and we know how much spacing we need between the two of them. Now if I wanted to, I could go ahead and throw some headers and footers in here and just as part of the exercise here, if I were to do that, I would want that header based off of the grid. So if I draw a header here and then let's just make it a little bit more palatable by making a little lighter, I would need to think about how tall I want this header to be. And because I have this snapping to the grid, I can just say okay, along which gridline do I think it's going to be appropriate for my header? And a lot of that of course is going to be what's up there.

In this case, I am just going to go ahead and create a header of 128 pixels. Notice it's still based on that grid line and now for my header, at least I know what the height of the header is going to be, and the height of the header here is going to be 128 pixels. So I'm fond of saying, and you have heard me say this throughout the title, that a lot of times I know what my CSS is going to be before I ever open up my code editor, and I hope this gives you some idea as to kind of what I am talking about with that. I know that I am going to have a header, I know that I am going to have a left column and a right column, I know how tall the header is going to need to be, I know the amount of padding that's going to be on either column, and I know the amount of space that I want between the two of them.

So that gives us a fantastic starting point for our fixed-width two-column layout. Now I am betting that based on everything we have covered up to this point, you probably have a pretty good idea of what our initial HTML structure of the file is going to look like, and what the initial styles are going to be as well, and we are going to test that out in our next movie as we write the styles for our layout based on the grid that we've just created.

There are currently no FAQs about CSS: Page Layouts.

 
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.
Upgrade now


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 Upgrade now

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

Notes cannot be added for locked videos.

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.