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 Web Site Design
Illustration by

Padding


From:

CSS Web Site Design

with Eric Meyer

Video: Padding

In this video we're going to add padding, having done margins and borders, already as you can see we have in our style sheet and now we're going to put some padding on things. Now padding is the space between the content of an element and the border. And it's part of the background area so any padding we add the background of the element is going to extend into that padding. A good example of this is with the navlinks, that purple bar that we've got going across the top. We'll give that let's say half of em of padding on the top and the bottom and three ems of padding on the side. If we reload, there you go, the navlink bar is gotten larger that half of the padding on the top and bottom, basically pushes extra space between the content area, which is where all those list items and links are, the about us and brewing and so on, and the edges of the background area. In technical fact, paddings between the content edge and the inner border edge. So if we had a border around the navlink here, then the padding would actually be the distance between the content and the inside of that border. We don't have that. We're going to see that in a moment when we do some padding in the content.
Expand all | Collapse all
  1. 14m 34s
    1. Welcome
      28s
    2. What is CSS?
      5m 34s
    3. Design tour
      2m 38s
    4. Using the exercise files
      1m 20s
    5. Installing the Web Developer toolbar
      4m 34s
  2. 25m 56s
    1. XHTML essentials
      3m 55s
    2. CSS essentials
      5m 17s
    3. Embedded style sheets
      2m 20s
    4. Linking a style sheet
      2m 19s
    5. Linking to multiple style sheets
      2m 20s
    6. Using linked and embedded style sheets together
      4m 21s
    7. Using imported style sheets
      5m 24s
  3. 57m 48s
    1. ID selector essentials
      6m 38s
    2. Class selector essentials
      4m 9s
    3. Best practices for classes
      4m 52s
    4. Grouped selection
      4m 2s
    5. Descendant selectors
      6m 44s
    6. The sources of style
      6m 38s
    7. Specificity
      8m 21s
    8. Making things important
      4m 32s
    9. Inheritance essentials
      5m 12s
    10. Making things really unstyled
      4m 2s
    11. User style sheets
      2m 38s
  4. 39m 3s
    1. Box model essentials
      7m 35s
    2. Simple floating
      5m 3s
    3. Using float for layout
      5m 5s
    4. Fixing column drop
      5m 35s
    5. Clearing essentials
      4m 20s
    6. Float containment
      6m 35s
    7. Creating a navbar from a list
      4m 50s
  5. 38m 3s
    1. Coloring text
      4m 13s
    2. Defining color in CSS
      8m 12s
    3. Coloring backgrounds
      6m 35s
    4. Applying background images
      4m 19s
    5. Manipulating the direction of background images
      2m 52s
    6. Positioning backgrounds
      7m 23s
    7. Background shorthand
      4m 29s
  6. 58m 28s
    1. Altering line height
      7m 32s
    2. Font style and weight
      5m 45s
    3. Sizing fonts
      9m 59s
    4. Using font families
      10m 38s
    5. Font shorthand
      6m 5s
    6. Justifying text
      4m 56s
    7. Vertically aligning text
      4m 22s
    8. Transforming text
      3m 49s
    9. Text decoration
      5m 22s
  7. 44m 40s
    1. Margin essentials
      14m 21s
    2. Adding borders
      6m 52s
    3. Padding
      9m 17s
    4. Using negative margins
      7m 19s
    5. Margin collapsing
      6m 51s
  8. 20m 38s
    1. Styling tables and captions
      5m 23s
    2. Styling table cells
      6m 30s
    3. Styling a column with classes
      4m 51s
    4. Styling links inside table cells
      3m 54s
  9. 30m 40s
    1. Styling for specific mediums
      4m 3s
    2. Creating a print style sheet
      6m 35s
    3. Hiding layout for print
      4m 11s
    4. Styling for print
      6m 34s
    5. Complex styling for print
      4m 37s
    6. Creating a footer
      4m 40s
  10. 37m 23s
    1. Getting started
      1m 11s
    2. Setting global styles
      4m 4s
    3. Defining masthead and navbar colors
      3m 27s
    4. Layout of the navlink bar
      3m 38s
    5. Using columns
      4m 49s
    6. Setting content styles
      1m 53s
    7. Creating the sidebar boxes
      5m 42s
    8. Creating the sidebar form
      3m 23s
    9. Completing the sidebar
      3m 29s
    10. Making a table
      3m 12s
    11. Creating a footer
      2m 35s
  11. 1m 28s
    1. Goodbye
      1m 28s

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 Web Site Design
6h 8m Intermediate Sep 12, 2006

Viewers: in countries Watching now:

CSS gives Web designers control over the appearance of their web sites by separating the visual presentation from the content. It lets them easily make minor changes to a site or perform a complete overhaul of the design. In CSS Web Site Design, instructor and leading industry expert Eric Meyer reviews the essentials of CSS, including selectors, the cascade, and inheritance. The training also covers how to build effective navigation, how to lay out pages, and how to work with typography, colors, backgrounds, and white space. Using a project-based approach, Eric walks through the process of creating a Web page, while teaching the essentials of CSS along the way. By the end of the training, viewers will have the tools to master professional site design. Exercise files accompany the training videos.

Subjects:
Web Web Design
Software:
CSS
Author:
Eric Meyer

Padding

In this video we're going to add padding, having done margins and borders, already as you can see we have in our style sheet and now we're going to put some padding on things. Now padding is the space between the content of an element and the border. And it's part of the background area so any padding we add the background of the element is going to extend into that padding. A good example of this is with the navlinks, that purple bar that we've got going across the top. We'll give that let's say half of em of padding on the top and the bottom and three ems of padding on the side. If we reload, there you go, the navlink bar is gotten larger that half of the padding on the top and bottom, basically pushes extra space between the content area, which is where all those list items and links are, the about us and brewing and so on, and the edges of the background area. In technical fact, paddings between the content edge and the inner border edge. So if we had a border around the navlink here, then the padding would actually be the distance between the content and the inside of that border. We don't have that. We're going to see that in a moment when we do some padding in the content.

This is also how we're going to push those borders apart from the links. Right now we have those vertical separator borders that are jammed right up against the right edge of each of the list items, so, it's just simple padding right of, in this case we're going to go three quarters of an em, hit Reload, there you go. They push apart, have these lovely separators between each of the links. You might wonder why do we have a right margin of half em and a right padding of three quarters of an em and that's actually an interesting question. The reason being that the white space between each of these list items, counts for a little bit of space.

So that carriage return or line feed if you prefer in tab that I have highlighted there creates a little bit of a separation between the contents of two list items and experience has shown me that that tends to be about a quarter of an em, so the right margin of half an em, plus the cord around that sort of intrinsic white space handling separation comes out to about a three quarters of an em, which is why when you look at the borders, they seem to be centered between the base for the link text in each case. So we can just keep going with that for the homelink link which is what it is time to write.

we can give it a couple of ems of top padding and no right padding and a half em of bottom padding and 1em of left padding, just like that and then if you look at the Javaco tea a bit, and extends outward and suddenly the mass area is taller. Also the background area gets taller and notice the white curl image there in the upper right hand corner of the strain that's actually a background on the homelink link. We're using padding to make that hyperlink bigger, so that we can see all that background image. If we used margins instead of padding here then be background area would be smaller, because margins don't extend the background area, only padding does and so we might have that background image get cut off.

So that's why we're using padding there. We can continue on with adding some padding. For example, the content each one here, which is the one that has the weight box around it, we might give it a similar lead to the navlinks, a half an em of top bottom padding and a couple of ems of right and left padding and then the h2. That's the one that has the green bottom border underneath it. We're going to use some bottom padding to push the border away from the content of the h2.

So when we go back over and hit Reload, you'll see that the white area around about tea history is going to get larger and the border is going to push itself away from The Legendary Origins of Tea text, just like that. That's that half em of padding helping us out on The Legendary Origins of Tea, giving us something that's pretty much like what we saw with the designers comp. so only the about tea history is sort of spread apart and we're not done with those things we actually in an upcoming video, we'll talk a little bit about how to finish up the last polish points, but for now this is how we're going to make this work.

So let's go back and actually add a little bit of padding over in the sidebar. If you look over here, there's no padding around the form. Basically the text input in the search box in the form element is just shrunk wrapped around basically the the contents there, and the same thing with the tea of the day in the post archive headings are very sort of constrained and for that matter, if you look at the interior of the tea of the day box, where it says Labrador Tea and it's got some text, that stuff is all grayed up against the edges of the div that's creating that box. We don't want that. We actually want to push those in a little bit so there's visual separation between the contents and the edges of the box. We probably want to do that even if that weren't what the comp calls for, just because honestly this just doesn't look very good and that's, it's kind of annoying to read, so we want to fix it anyway, and that's what we're going to do. For the form we can give it some all around padding with the 8/10 of an em or 4/5 of an em if you prefer, and then for the divs we're going to give them no top padding, some right and left padding and some bottom padding.

Now, the reason that we do want to give them any top padding, if we go back to Firefox, if we gave them top padding, that would push the tea of the day in the post archive headings downwards and would put gray above them and that's not what we want according to the designers comp. We just what to push things inward and the bottom padding will prevent things like you can see here, where the tea of the day picture is jammed right up against the bottom of that div box. That's actually not such a bad effect in my opinion, but it's not what the designer called for. If you look in the comp, you can see that the designer has space set out there so we want to recreate that and this padding of 0 1em 1em will help do that, and if we reload, there you can see, we've created some extra space.

But wait a minute you say, those headings just got pushed inward, post archive in the tea of the day. Yes, there's really no way to say, apply padding to all of the contents of this element except for the ones I don't want to, you can directly say that in CSS but you can fake your way around it and we're going to find out in the next video. For now we're just going to have to accept that that's the state of things and will take steps to overcome them later. As for why we used eight tens of an em for the form, that just seemed to be about the right amount when compared to the visual comp. The comp actually looks like there might be slightly more than that and we can fit it with that if we like, we can say, well maybe 0.8em then maybe that's good on the sides and maybe we want one quarter em on the top and bottom and we'll just go and we'll reload and maybe that's a little better. The nice thing about CSS of course being that you can just go to the style sheet, fill it with some numbers, you know, do some trial and error if you like it and it really doesn't cost you a whole lot to do that. So there's really only a couple more things I'd like to do here before we move on to the next video. One is to add a little bit of padding to those h3s, that would be the tea of the day and the post archive. I want to get some top and bottom padding cause if you look again in the comp, they're nice and spacious and so I'd like to recreate that and here it is, just like that.

And then the last thing is at least in the sidebar is for this tea of the day, Labrador Tea, where it says Labrador Tea, if you look, it has a little bit of spacing and the top as well so we're just going to take care of that. And then the last little bit is just the footer, so that we can recreate as much of the space as we can, shown there, in the footer in the design comp, and so if you reload, you notice Labrador Tea kind of stretches out and there's the footer gotten all nice and tall.

So that's how you add padding. As I said before, there are obviously some things that we need to clear up like the space around the post archive, the tea of the day headings and also for that matter of a fact that the about tea history white box doesn't go over to left as far as it should according to the design comp, and for that matter, the fact that there's blank space between the edges of the browser window and all of the content, look around the masthead, the design comp, doesn't really want it that way, so we need to get rid of that and in the next video we're going to do all that stuff.

There are currently no FAQs about CSS Web Site Design.

 
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 Web Site Design.

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

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.