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

Applying padding and margins

From: Creating a CSS Style Guide: Hands-On Training

Video: Applying padding and margins

Although it's beginning to look more page-like and more like a style guide that we might show around our team, it's still too tight. We have no negative and positive space. We really need to talk about margins and padding. It's confusing to beginners, it's even confusing to people who have been doing it a long time, but as you can see, the box is clearly evident. If I add margins, that will add space or push away from the box. Think of your hand going out to the side and pushing someone away.

Applying padding and margins

Although it's beginning to look more page-like and more like a style guide that we might show around our team, it's still too tight. We have no negative and positive space. We really need to talk about margins and padding. It's confusing to beginners, it's even confusing to people who have been doing it a long time, but as you can see, the box is clearly evident. If I add margins, that will add space or push away from the box. Think of your hand going out to the side and pushing someone away.

If I add padding, it goes inside the box, so think of taking your hands and holding yourself tightly. It goes away from the inside edge. For instance, if we are shipping something with FedEx, we would put padding inside in the box. That's the way I think of it. I really do literally think of it as sort of like packing a box, things outside the box and inside the box. I'll say it one more time. Pushing away outside the box, margin; putting something inside the box would be padding and pushing away from the inside edge of that box.

So let's go back into Dreamweaver and see if we can get some of the negative space and some of the padding that this page needs so desperately. Click on the document window to refocus and where we need to add the padding is in that Content box. That's where there is no give. That's where there is no breathing room. So let's return to the CSS Style Guide and scroll to the bottom to look for our content ID style. Double-click on that. Let's go to the Box Category.

In padding, let's try putting 20 pixels. I'm just guessing that that might be a good number and let's click Apply. Immediately we get that breathing room. That text is now coming away from the edge. It's kind of floating and holding its own space, which is exactly what we want. Padding is a good thing if you understand the box that's containing it and that it's moving away from the edge of that box. I'm going to click OK. Again, I'm going to look down through my page and just check for few other things. Now that I have added that padding, there is no reason this table can't be the full 100%, because I know that the 20 pixels on the left and the right will keep it from going clear across the browser. So I'm going to put my I-beam inside the table. Go to the Tag Inspector and select that tag table and down in the Property Inspector where it says Width, I'm going to type 100%. Then I'll Tab out. That looks good.

Let's go File > Save All and let's take one last look at the page inside the browser to make sure that it's got the right proportions of negative and positive space and that we have used margins and padding correctly. Now that looks like a page. That's looking very, very good. See how the table is holding its own, stretching clear across and stopping right at the 20 pixels on the left and right. We have some breathing room on the bottom of 20 pixels. On both sides we have 20 pixels and right at the top it's starting to look like a real webpage.

Margins and padding are difficult to understand when you first start learning to do web design. But we are lucky. This page looks good. We have styled it correctly and we have a way by using our Firebug toolbar to check out our padding and margins. Over on the left you see our body tag, but we really want to look at our content Div. As soon as I roll over the word content, look what Firebug does for us automatically. The aqua color says that is what your Box is and the purple color shows us padding. This indicates that we have 20 pixels all the way around this box. So the purple is inside the box.

If I dig down inside the hierarchy here and go down to h2. In this case, it's yellow green and it's outside of the box. This is margin, not padding. So if you ever really want to see how is it working, is it padding, is it margin, is it inside the box or outside the box? Use your Firebug application to check your margin and padding and be able to understand the box model. There is one other thing I want to show you that exists inside of Firebug is this layout model. As I hover over different IDs, different tags, this model will continue to change and show me what's going on with this particular page.

Now it's not proportional. I actually think the view in the window is much easier to understand. Remember, purple is padding and yellow green is margin outside the box. To close this window up, just simply click here. Take one more look at your page. Make sure everything is breathing, standing on its own and holding its own on the page.

Show transcript

This video is part of

Image for Creating a CSS Style Guide: Hands-On Training
Creating a CSS Style Guide: Hands-On Training

35 video lessons · 28084 viewers

Laurie Burruss
Author

 
Expand all | Collapse all
  1. 6m 58s
    1. Welcome
      1m 9s
    2. Objective of this course
      3m 38s
    3. Using the exercise files
      2m 11s
  2. 28m 26s
    1. Starting Dreamweaver for the first time
      3m 38s
    2. Defining a website
      4m 3s
    3. Understanding the Dreamweaver interface
      9m 43s
    4. Setting up a custom workspace
      4m 10s
    5. Setting essential preferences
      6m 52s
  3. 56m 54s
    1. Laying out a page in a text document
      3m 40s
    2. Creating and saving a new document
      3m 27s
    3. Inserting an image
      8m 22s
    4. Marking up text using the Property Inspector
      6m 48s
    5. Marking up text by hand
      9m 21s
    6. Inserting, formatting, and selecting a table
      8m 16s
    7. Creating links
      12m 26s
    8. Styling a footer
      4m 34s
  4. 22m 15s
    1. Using Modify Page Properties to create embedded styles
      12m 22s
    2. Creating links with CSS
      4m 55s
    3. Working with Code, Split, and Design views
      4m 58s
  5. 8m 52s
    1. Defining browsers to test a web page
      2m 24s
    2. Previewing a web page in a browser
      6m 28s
  6. 16m 44s
    1. Using a span tag to add a class and customize appearance
      10m 34s
    2. Using the Tag Inspector to create and edit additional styles
      6m 10s
  7. 48m 42s
    1. Exporting existing styles into an external style sheet
      7m 0s
    2. Using the CSS Styles panel to add a new style
      5m 43s
    3. Using the div tag to create a content container
      11m 8s
    4. Overriding the default browser styles
      2m 46s
    5. Applying padding and margins
      4m 57s
    6. Styling header tags
      5m 34s
    7. Creating and styling compound tags
      5m 12s
    8. Editing preexisting rules
      6m 22s
  8. 19m 36s
    1. Improving the Footer
      5m 12s
    2. Commenting a CSS style sheet
      7m 0s
    3. Creating a custom color palette
      7m 24s
  9. 3m 6s
    1. Style sheet final review
      3m 6s

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.

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 Creating a CSS Style Guide: Hands-On Training.

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.