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

Managing white space with margins, padding, and line height

From: Dreamweaver CS3 Essential Training

Video: Managing white space with margins, padding, and line height

Probably one of the most overlooked, but highly necessary tools to use when you're styling a page is white space. The web is full of text, and the devices we have to read the text really aren't suited for the job, because the typical desktop printer prints at over 600 dots per inch, whereas the monitor sitting on your desk can't show more than 72, or 90 six pixels per inch. Reading text on a screen is far more difficult than reading it on paper, and because of this lower resolution, using lots of white spaces in order to make your pages easier to read. So, in this exercise we'll learn how to learn how to manage the white space of our text using margins, padding, and line height. We're still working with the aboutus.html file here, and in this exercise, we're going to try to tighten up the space around the headings that we see here, and create more space between the text and the paragraphs.

Managing white space with margins, padding, and line height

Probably one of the most overlooked, but highly necessary tools to use when you're styling a page is white space. The web is full of text, and the devices we have to read the text really aren't suited for the job, because the typical desktop printer prints at over 600 dots per inch, whereas the monitor sitting on your desk can't show more than 72, or 90 six pixels per inch. Reading text on a screen is far more difficult than reading it on paper, and because of this lower resolution, using lots of white spaces in order to make your pages easier to read. So, in this exercise we'll learn how to learn how to manage the white space of our text using margins, padding, and line height. We're still working with the aboutus.html file here, and in this exercise, we're going to try to tighten up the space around the headings that we see here, and create more space between the text and the paragraphs.

First thing we're going to do is adjust the Line height of the paragraphs, and we did something very similar to this in the chapter on Cascading Style Sheets. Let's go over to the CSS panel, and we're going to create a New style. And, we're going to select Tag and we'll just select the "p" tag to redefine in this case. We're going to make sure we're adding this to our external style sheet. We'll click on OK. And, for the Line height, we're going to choose 1.7 ems. Click on OK. And, you can see that's now added more space between the lines in the paragraph. Now, how did I come up with 1.7 ems? Basically, I experimented with a bunch of different settings until I found one that looked good to me, but there is actually a formula that you can use to try to determine what an optimal line height might be. Line Height, by definition, is the total height of the line of text, including the white space above and below the actual characters. In this particular paragraph here, we can see that the Line height is a space above and below each line. So, if you set the font size of a paragraph to 10 pixels, and then you set the line height to 20 pixels. You can calculate the amount of white space that's going to appear above, and below the line of text with this equation. Basically, you want to take a line height, subtract the font size, and divide by two, and that will give you the amount of white space above and below the text.

So, with a font size of 10 pixels, and a Line height of 20 pixels, the math looks like this: (20 -10) is 10 divided by 2 = 5 pixels. So, this means that a Line height of 20 pixels on paragraph with the font size of 10 pixels is going to have 5 pixels of the white space above the characters, and 5 pixels of white space below the characters. Setting the Line height to twice the font size is pretty much the same as setting a paragraph to be double-spaced in a word processing program. But if you're not a math person, and I sure am not, and you don't want to deal with this sort of formula, basically, just look at the text and see how it looks to you.

If the Line height looks like it could be larger, or smaller, just go back into your style sheet, and change it. If you're more into precise calculations, just use this formula, and you can figure out Line height that way. Let's go back to {italic}Dreamweaver {plain}. We've added this extra Line height to the paragraph Tag. Now, we want to tighten up the space between the h1 Tag, which is about "Our Goal" here, and the image that's immediately following it, and the first to doing this is changing the margins on the h1 Tag. So, in the CSS panel I'm going to find my h1 Tag, and I'm going to choose to edit it.

We're going to go over to the Box category, and I only want to change the space below the h1 Tag. I like the amount of space that's above it right now. So, I'm going to uncheck "Same for all" under margin, over here. And we'll set the bottom to 12 pixels. So, that will still give us some space, but not nearly as much space as we see right now. Let's click OK, and watch what happens to the space between the text, and the image. Absolutely nothing. The reason we didn't see a change is because of the way margins are calculated by {italic}Dreamweaver,{plain} and by browsers, and this takes a little bit of explanation as well. So, that change we made to the h1 role didn't effect the display of the document because of the way margins are calculated. Every element on the page has a margin, and text elements, headings, and paragraphs have built-in margins. So, two adjacent elements like this, the heading, and the paragraph containing the image, share their margins. And, the larger of the two margins is used to separate the two elements. So, let's say the h1 Tag has12 pixels on the bottom margin.

We're seeing those with those lines that I've drawn here. But, the paragraph containing image has a default margin of about 20 pixels, which is roughly twice the font size of the paragraph. We say about 20 pixels because this is the browser default margin that's being drawn, which can be different from browser to browser. When the browser decides how far to space the two elements apart, it collapses the margins. Basically, overlapping them, or placing them on top of each other, so that the space between the two elements is equal to the larger of the two margins. So, in this case it doesn't matter that we changed the h1 margin to 12.

The margin for the image was still much larger, in this case about 20 pixels, so that is still considered the margin that's going to appear between those two items. So, to finish collapsing the space between the header and the paragraph, we also need to redefine the "p" tag for this element. Let's go back to {italic}Dreamweaver,{plain} and do. So, back here in {italic}Dreamweaver, {plain}I'm going to come back over to my CSS Styles panel, and I'm going to edit the "p" Tag. Let's go back to the Box category where we were before, and in the Margin section, we're going to again uncheck Same for all, and I'm going to set a Top margin of 0 pixels. That will basically eliminate that Top Margin, and then default to the h1's margin, which is 12 pixels. Just remember that the browsers always default to the larger of the two margins. Let's click OK. And, you can see now our image has shifted up a little bit closer to the h1 Tag, and now there's a little less space in there, and it looks little bit better. To tighten up the space around the h2 Tag, we just need to come and find the h2 Tag, we can double- click it to edit it. Go back to the Box category again, and in the margin section we'll set the Top to 0 pixels, and we'll set the Bottom to 12 pixels.

And, watch what happens, and we've tighten it up a little bit more. Notice the top didn't really move because it still relying on the margin for the bottom portion of the images paragraph. I actually think the spacing here is ok so, I'm going to leave it just like. Now, the page is looking a little bit better. The headers are spaced nicely around the image, and the paragraph of text is much easier to read with that extra Line height. The last thing I want to do is, differentiate the h2 Tag by adding that small colored border to the left side of the text to make it look like a little bit of a bullet. This is exactly what we did in previous chapter with Cascading Style Sheet, but we did it all from the Properties section of the CSS Styles panel. But, this time we'll actually go into the CSS styles Edit dialog box to make this change. Lets put out cursor in that h2 area. We'll come in, we'll double-click the h2 rule.

Go over to the Border category, and we're going to unchecked Same for all of these because we only want to set up a box to the left here. Basically, if we wanted to we could set up a border around the entire bit of text here, but I only want something along the left hand side. We want that to be solid. We'll set the size to be 11 pixels in width, and will set the color to "D7DACE". Make sure we get the "#" in there. Lets click on OK.

And there's the box there. If I put that on all four sides, I'd have a thick 11 pixel border around the entire block of text here. Because I only put it to the left, I can make it look like it's just a bullet point. But again, the border is right up against the text here, so I want to add a little bit of padding in here. So, lets go back to the h2 rule again. Lets go over to Box. We're going to uncheck Same for all for Padding, and to the left side, we're going to add 7 pixels of Padding. Click on OK. And now we have some nice space between that box in the text there. So, it's important to understand the difference between Margin, and Padding.

Basically Margins control the space outside a block of text. Padding controls the space inside the block of text. So, you can see that here, the Padding for a box of text is added between the text, and the border applied to the box. So, when you actually show a border around the text, you have to have some Padding in there, or else the border will touch right up to the text, which is what you don't want in most cases. Now, if you want extra space outside of that border, that's when you add a Margin. So think of it this way, the Padding is inside the box. Think of a padded box or a padded cell, and the Margin is the space outside.

So, if something we're going to go next block, and I didn't want it to come right up to the block of the text itself, I would add more of a Margin. If I want more space between the text in the border, we add Padding. So, that's the difference between Margins and Padding, and I think you'll agree now that we've added a little more white space to this document, it's looking a lot cleaner, and definitely a lot more readable.

Show transcript

This video is part of

Image for Dreamweaver CS3 Essential Training
Dreamweaver CS3 Essential Training

129 video lessons · 86988 viewers

Garrick Chow
Author

 
Expand all | Collapse all
  1. 1m 12s
    1. Welcome
      1m 12s
  2. 21m 0s
    1. HTML vs. XHTML
      3m 4s
    2. What is CSS?
      3m 48s
    3. What is XML?
      2m 11s
    4. What is DHTML?
      1m 9s
    5. What is JavaScript?
      1m 23s
    6. File naming conventions
      3m 22s
    7. What is an index page?
      6m 3s
  3. 46m 18s
    1. Setting up your workspace
      2m 39s
    2. The Welcome screen
      4m 11s
    3. Windows and Mac differences
      3m 18s
    4. The Insert bar
      4m 38s
    5. The Property Inspector
      1m 50s
    6. The Document toolbar
      6m 6s
    7. The Document window
      9m 11s
    8. Panels and panel groups
      6m 58s
    9. Saving workspace layouts
      2m 22s
    10. Defining a default browser
      5m 5s
  4. 24m 59s
    1. Defining a site
      9m 5s
    2. File and folder management
      3m 11s
    3. Understanding path structure
      3m 17s
    4. Adding content to a site
      6m 6s
    5. Creating a site map
      3m 20s
  5. 38m 39s
    1. Creating a new blank site
      6m 0s
    2. Creating and saving a new document
      7m 54s
    3. About DOCTYPE
      3m 59s
    4. Inserting images
      9m 26s
    5. Inserting text
      3m 35s
    6. Aligning text and images
      4m 9s
    7. Inserting meta tags
      3m 36s
  6. 45m 58s
    1. Link basics
      6m 4s
    2. Linking with Point to File
      5m 18s
    3. External links
      4m 15s
    4. Creating email links
      5m 49s
    5. Named anchors
      7m 37s
    6. Linking to a file
      7m 35s
    7. Image maps
      9m 20s
  7. 1h 8m
    1. About CSS
      4m 52s
    2. Anatomy of a style sheet
      4m 10s
    3. CSS and page properties
      10m 11s
    4. Moving an internal style sheet to an external style sheet
      6m 46s
    5. The CSS Styles panel
      3m 48s
    6. CSS selectors
      2m 37s
    7. Type selectors
      12m 13s
    8. ID selectors
      10m 21s
    9. Class selectors
      5m 42s
    10. Creating rollovers with pseudo-class selectors
      7m 22s
  8. 42m 54s
    1. CSS vs. the Font tag
      2m 42s
    2. Formatting text with the Property Inspector
      8m 41s
    3. What measurement should I use?
      3m 15s
    4. Managing white space with margins, padding, and line height
      8m 34s
    5. Using font lists
      5m 45s
    6. Aligning text
      2m 47s
    7. Creating lists
      5m 8s
    8. Creating Flash text
      6m 2s
  9. 43m 19s
    1. About tables
      1m 28s
    2. Tables in Code view
      2m 36s
    3. Creating and adding content to tables
      7m 40s
    4. Changing table borders with XHTML
      5m 46s
    5. Coloring tables with XHTML and CSS
      6m 41s
    6. Aligning table content
      6m 39s
    7. Sorting tables
      3m 6s
    8. Setting table widths
      4m 48s
    9. Creating rounded-corner tables
      4m 35s
  10. 28m 22s
    1. Dreamweaver's layout tools
      3m 8s
    2. Tracing images
      4m 58s
    3. Adding AP div tags
      7m 29s
    4. Working with Layout Tables
      6m 55s
    5. Adjusting table widths and nesting tables
      5m 52s
  11. 16m 19s
    1. What is a device?
      3m 14s
    2. Attaching a printer-friendly style sheet
      3m 5s
    3. Styling for print
      7m 41s
    4. Adobe Device Central
      2m 19s
  12. 29m 54s
    1. Rollover rules
      3m 31s
    2. Creating simple rollovers
      5m 36s
    3. Creating disjointed rollovers
      7m 12s
    4. Creating navigation bars with multiple states
      9m 21s
    5. Creating Flash buttons
      4m 14s
  13. 26m 32s
    1. Viewing the code
      6m 9s
    2. Editing in Code view
      3m 0s
    3. The Code toolbar
      5m 11s
    4. Working with Code Collapse
      4m 27s
    5. The Quick Tag Editor
      2m 20s
    6. Working with snippets
      5m 25s
  14. 32m 45s
    1. About forms
      3m 23s
    2. Adding text fields
      9m 52s
    3. Adding checkboxes and radio buttons
      5m 37s
    4. Adding lists and menus
      6m 5s
    5. Submitting form results
      3m 23s
    6. Styling form elements with CSS
      4m 25s
  15. 23m 17s
    1. Opening a new browser window
      9m 38s
    2. Creating a popup message
      2m 50s
    3. Validating text fields
      2m 42s
    4. Getting more behaviors
      7m 2s
    5. Removing extensions
      1m 5s
  16. 14m 58s
    1. External image editor preferences
      3m 18s
    2. Built-in image editing tools
      3m 11s
    3. Roundtrip editing from Dreamweaver to Fireworks or Photoshop
      4m 39s
    4. Copying and pasting
      3m 50s
  17. 34m 16s
    1. Templates in action
      5m 12s
    2. Creating a new template
      6m 36s
    3. Applying templates
      3m 36s
    4. Modifying a template
      1m 40s
    5. Adding repeating regions
      3m 28s
    6. Working with repeating regions
      3m 13s
    7. Adding optional regions
      3m 34s
    8. Creating a library item
      3m 48s
    9. Modifying a library item
      3m 9s
  18. 13m 2s
    1. Using the History panel
      4m 24s
    2. Saving History steps as commands
      3m 25s
    3. Using Find and Replace
      5m 13s
  19. 14m 44s
    1. W3C accessibility guidelines
      4m 6s
    2. Accessibility preferences
      1m 29s
    3. Inserting accessible images
      3m 2s
    4. Inserting accessible tables
      2m 53s
    5. Inserting accessible form objects
      3m 14s
  20. 26m 17s
    1. About media objects
      2m 6s
    2. Linking to audio and video files
      5m 56s
    3. Embedding audio and video files
      7m 7s
    4. Setting parameters
      4m 27s
    5. Inserting Flash content
      2m 37s
    6. Inserting Flash video
      4m 4s
  21. 28m 47s
    1. Getting site reports
      3m 35s
    2. Checking links sitewide
      3m 30s
    3. Signing up with Tripod
      6m 36s
    4. Entering remote info
      4m 13s
    5. Publishing your site
      5m 41s
    6. Updating and publishing pages
      5m 12s
  22. 44s
    1. Goodbye
      44s

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 Dreamweaver CS3 Essential 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.