Dreamweaver CS4 Essential Training
Illustration by Don Barnett

The Box Model


From:

Dreamweaver CS4 Essential Training

with James Williamson

Video: The Box Model

Before we move on to talk about floating and positioning, but we need to first discuss the box model. Understanding the box model is crucial to controlling page layout. Every element in your document is contained within a box, even the inline level elements. Browsers use an element's box properties to determine how much space it takes up in the layout. Taking control of these values allows you a lot more control over your layout. The box model is made up of five basic properties; an element's width, height padding, border and margins. Backgrounds do take advantage of the box model and they display all the way inside of an element to the element's border but they aren't technically part of the box model. So when you're defining an element's width and height, a lot of people have the mistaken impression that that is the entire width and height of the element. And that's not true.
Expand all | Collapse all
  1. 1m 52s
    1. Welcome
      1m 13s
    2. Using the exercise files
      39s
  2. 14m 50s
    1. Basic site structure
      2m 16s
    2. What is an index page?
      1m 34s
    3. Current web design practices
      2m 21s
    4. What is XHTML?
      3m 9s
    5. What is Javascript?
      1m 38s
    6. What is CSS?
      1m 51s
    7. File naming conventions
      2m 1s
  3. 24m 0s
    1. The Welcome screen
      3m 33s
    2. Windows and Mac interface differences
      2m 7s
    3. The Application toolbar
      2m 34s
    4. The Document toolbar
      3m 0s
    5. Arranging panels
      4m 43s
    6. Managing workspaces
      4m 14s
    7. The Properties Inspector
      3m 49s
  4. 18m 27s
    1. Defining a new site
      4m 12s
    2. Managing sites
      3m 59s
    3. Managing files and folders
      6m 3s
    4. Setting a default browser
      4m 13s
  5. 15m 14s
    1. Creating new documents
      3m 51s
    2. DOCTYPE declarations
      4m 44s
    3. New document preferences
      2m 37s
    4. Working with starter pages
      4m 2s
  6. 20m 14s
    1. XHTML structure
      2m 27s
    2. Structuring content
      4m 11s
    3. Creating lists
      6m 22s
    4. Getting text into Dreamweaver
      4m 11s
    5. Importing Word documents
      3m 3s
  7. 52m 5s
    1. Understanding style sheets
      1m 59s
    2. Anatomy of a CSS rule
      1m 32s
    3. Setting CSS preferences
      3m 56s
    4. The CSS Styles panel
      6m 36s
    5. Controlling CSS through the Properties Inspector
      4m 51s
    6. Using the Code Navigator
      4m 52s
    7. Understanding Element Selectors
      6m 4s
    8. Understanding Class Selectors
      5m 39s
    9. Understanding ID Selectors
      5m 35s
    10. Understanding Descendent Selectors
      5m 30s
    11. Attaching external style sheets
      5m 31s
  8. 1h 0m
    1. Working with units of measurement
      4m 33s
    2. Declaring font families
      6m 3s
    3. Controlling font sizing
      3m 57s
    4. Controlling weight and style
      6m 13s
    5. Controlling line height
      5m 26s
    6. Controlling vertical spacing with margins
      6m 45s
    7. Controlling spacing with padding
      6m 1s
    8. Aligning text
      5m 25s
    9. Transforming text
      4m 27s
    10. Using the cascade to control styling
      11m 56s
  9. 1h 2m
    1. Understanding image types
      5m 1s
    2. Managing assets in Dreamweaver
      8m 30s
    3. Setting image accessibility preferences
      3m 44s
    4. Placing images on the page
      7m 45s
    5. Modifying image properties
      8m 6s
    6. Customizing images through CSS
      6m 4s
    7. Photoshop integration
      5m 16s
    8. Setting external image editing preferences
      2m 7s
    9. Modifying Smart Objects
      4m 9s
    10. Alternate Photoshop workflows
      5m 45s
    11. Using background graphics
      5m 42s
  10. 31m 3s
    1. Link basics
      3m 10s
    2. Setting site linking preferences
      1m 25s
    3. Creating links in Dreamweaver
      4m 55s
    4. Absolute links
      4m 8s
    5. Using named anchors
      4m 26s
    6. Linking to named anchors in external files
      2m 49s
    7. Creating an email link
      5m 16s
    8. Creating CSS-based rollovers
      4m 54s
  11. 39m 17s
    1. CSS structuring basics
      2m 19s
    2. Structuring with DIV tags
      8m 48s
    3. The Box Model
      5m 9s
    4. Understanding floats
      4m 42s
    5. Clearing and containing floats
      4m 47s
    6. Using relative positioning
      3m 7s
    7. Using absolute positioning
      5m 42s
    8. Using fixed postioning
      4m 43s
  12. 51m 26s
    1. Reviewing table structure
      4m 45s
    2. Importing tabular data
      4m 44s
    3. Creating accessible tables
      7m 39s
    4. Using thead and tbody tags
      2m 56s
    5. Basic table styling
      6m 36s
    6. Styling table headers
      5m 13s
    7. Styling column groups
      6m 30s
    8. Creating custom table borders
      4m 24s
    9. Adding user interactivity to tables
      5m 12s
    10. Styling table captions
      3m 27s
  13. 1h 3m
    1. How forms work
      3m 5s
    2. Reviewing form design
      2m 51s
    3. Creating accessible forms
      4m 50s
    4. Setting form properties
      3m 46s
    5. The fieldset and legend tags
      3m 7s
    6. Inserting text fields
      5m 7s
    7. Inserting list menu items
      4m 35s
    8. Inserting radio button groups
      4m 34s
    9. Inserting checkboxes
      3m 15s
    10. Inserting text areas
      3m 37s
    11. Inserting submit buttons
      2m 31s
    12. Styling form elements
      6m 57s
    13. Adding form interactivity
      4m 19s
    14. Using Spry validation widgets
      10m 26s
  14. 35m 51s
    1. Planning for templates
      4m 0s
    2. Creating a new template
      3m 51s
    3. Creating editable attributes
      4m 55s
    4. Creating new pages from a template
      4m 57s
    5. Applying templates to existing pages
      3m 18s
    6. Working with nested templates
      5m 47s
    7. Working with repeating regions
      5m 42s
    8. Modifying templates
      3m 21s
  15. 35m 32s
    1. Behaviors overview
      2m 43s
    2. Getting more behaviors
      4m 44s
    3. Creating disjointed rollovers
      7m 6s
    4. Hiding and showing elements
      6m 7s
    5. Spry overview
      3m 3s
    6. Using Spry widgets
      5m 19s
    7. Adding Spry widgets
      3m 12s
    8. Using Live View and Related Files
      3m 18s
  16. 22m 1s
    1. Inserting Flash files
      3m 59s
    2. Setting properties for Flash
      4m 18s
    3. Dreamweaver and Flash integration
      3m 19s
    4. Encoding Flash video
      6m 55s
    5. Adding Flash video
      3m 30s
  17. 22m 57s
    1. Using the History palette
      3m 45s
    2. Saving history steps with commands
      2m 59s
    3. Creating library items
      4m 55s
    4. Updating library items
      5m 2s
    5. Using Find and Replace
      6m 16s
  18. 23m 50s
    1. The Code toolbar
      4m 35s
    2. Setting code preferences
      4m 24s
    3. Using code hints
      6m 1s
    4. Adding comments
      5m 8s
    5. Finding syntax errors
      3m 42s
  19. 20m 31s
    1. Running sitewide reports
      4m 9s
    2. Checking for broken links
      3m 10s
    3. Validating markup
      1m 52s
    4. Checking for browser compatibility
      3m 14s
    5. Entering remote information
      2m 6s
    6. Synchronizing sites
      3m 26s
    7. Updating and publishing files
      2m 34s
  20. 14s
    1. Goodbye
      14s

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now
please wait ...
Watch the Online Video Course Dreamweaver CS4 Essential Training
10h 15m Beginner Oct 13, 2008

Viewers: in countries Watching now:

To get the most out of Dreamweaver CS4, it's important not only to master the application, but also to understand fundamental concepts of modern web design. James Williamson teaches just that in Dreamweaver CS4 Essential Training, covering everything from site structure to the value of standards-compliant XHTML and CSS. He shows how to create clean and accessible code in Dreamweaver, as well as how to publish compelling content. James demonstrates how to use a variety of techniques for adding interactivity, creating and styling forms and tables, and saving time with templates. He explains the benefits of using programs like Word and Photoshop to speed up workflow, and shows how to publish and manage finished sites. Exercise files accompany the course.

Topics include:
  • Understanding current web design practices
  • Learning and customizing the Dreamweaver interface
  • Adding text and structure to an XHTML document
  • Implementing layouts and designs with CSS
  • Controlling all aspects of typographic presentation
  • Working with images, Flash, and video
  • Using behaviors and Spry widgets
Subject:
Web
Software:
Dreamweaver
Author:
James Williamson

The Box Model

Before we move on to talk about floating and positioning, but we need to first discuss the box model. Understanding the box model is crucial to controlling page layout. Every element in your document is contained within a box, even the inline level elements. Browsers use an element's box properties to determine how much space it takes up in the layout. Taking control of these values allows you a lot more control over your layout. The box model is made up of five basic properties; an element's width, height padding, border and margins. Backgrounds do take advantage of the box model and they display all the way inside of an element to the element's border but they aren't technically part of the box model. So when you're defining an element's width and height, a lot of people have the mistaken impression that that is the entire width and height of the element. And that's not true.

The specified width and height controls that content only. After the width and height of the contents, we have padding. The padding pushes the content away from the edge of the element itself. After the padding, we have the border. The border is optional but it can have a defined width, Color and Style. After borders, we have margins. margins help push our element away from other elements on the page and help us to find the relationship between one element to another. So if we are trying to calculate the entire width of an element, we have to calculate the width of the borders, the width of the padding so if we put 20 pixels over the padding, for example, all the way around our art work, we get 20 pixels on left, 20 pixels on right, so that's 40 pixels. And then finally, we have the width of the content.

Now if we don't define that width, the width is defined by the content itself or the area it's contained inside of. The best way to truly understand the box model is to control these properties for yourself. So let's dive in and set some values. Okay, here we are back in Dreamweaver and I have got the box_mode.htm file opened from the 10_03 folder. Now on our page, we have a paragraph which is contained inside of DIV tag with an ID of container. We are going to use those two elements to explore our box model properties. If you notice over the CSS Style panel, we already have selectors written for them and we can just start adding the properties that we need.

Let's start with the container element. Let's go and add a width property to that and I go ahead assign a width of 300 pixels. Go ahead and add a height property to it and give it height of 300 pixels as well. You can see the dramatic change in the container element, for example, we currently see the background of it now. Now choose the # containerp selector and let's affect the paragraph inside of it. Go ahead and give it a width of 100 pixels and then give it a height of 100 pixels as well. Now I want to point out that you shouldn't always trust what you see inside of a Dreamweaver. If we will save this file, for example, and Preview it in our Browser, you can see that the paragraph is aligning to the upper left hand corner of the container element and that's what we would expect but Dreamweaver is showing some default margins and padding that are not be taken into account here.

Now next stuff, we have got padding. So almost like the container element and I'm going ahead and add the padding property to it. Let's give it padding to 20 pixels. We will do the same thing for our interior paragraph. We give it padding but this time we will only do 10 pixels. Now note the change that just happened. Our container DIV tag just got a lot wider and the paragraph is now being restore from the edge and if we look inside of our paragraph, our paragraph is now a bit wider as well and note that text isn't budding up right against the edge of the paragraph either.

Now after padding, we have borders. So I'm going to go up to my container element. I will go and add the border Property and we will give it 1 pixel border solid #0000. So one pixel, solid black border. Let's select the paragraph inside the container. We will give it a border as well and we will give it 1 pixel solid #3333. So if I save that and test it, we can see a pretty dramatic change in our paragraph and how it's relating to its container element.

Let's finish this up by playing around little bit with margins. Go ahead and select your Container Paragraph, add a Property and go ahead and give it margin. Why don't we give it a margin of 20 pixels all the way around? Save that and test it. So now we are able to control the placement of the paragraph inside the parent element by using these margins. If we were to factor of the total width and height of this, notice we have 100 pixels wide Paragraph, we have 10 pixels of the padding on the either side so that's 120 pixels and then finally we have the border. So it's 122 pixels.

In terms of the distance that it is away from the edge of its container element, we have got 20 pixels worth of margin that go all the way round but also don't forget about the 20 pixels worth of padding that's inside of our container element. So it's actually being held off 40 pixels away from the top and left edges of the parent element. Now that we have handle on margins, borders, padding, height and width and how they affect overall dimensions and relationships with other elements on the page, we can move on to talk more about layout specific topics. Next stuff we will using the CSS Float Property for layout.

Find answers to the most frequently asked questions about Dreamweaver CS4 Essential Training .


Expand all | Collapse all
please wait ...
Q: In Dreamweaver CS4, is it possible – or recommended –  to use a table within a form, in order to line up the fields?
A: Using tables to layout forms is a common web design practice. There are drawbacks to doing so, because it reduces the accessibility of the form, but many, many designers use this technique. There are many ways to layout forms using CSS that don't require tables (see Chapter 8, "Styling Forms" in the Dreamweaver CS4 with CSS Essential Training title), but the forms will work fine should one choose to do so.
Q: How do I direct a link to an FLV movie to open in new browser window, using Dreamweaver CS4?
A: To link to an FLV in a new browser window, create a separate HTML page with nothing but the Flash video on it. Set the video to “autoplay = true”, since clicking the link will be all the input needed by the viewer to play the video. Align the video to the center of the page. (Use a div tag and center the div tag on the page). Make sure the new window opens to the size of the video player, making sure to allow for the browser;'s title bar, menus, chrome, etc. Also, if desired, offset the video byadding left="" and top="" attributes to the behavior. Enter the pixel amount for left and top offset or the window will always open aligned to the top left of the screen.
Q: The author states that the Mac OS version of Dreamweaver CS4 does not support the direct insertion of Word files, and that copy and pasting text from a Word file will format the text as links. How does one add and format text in Dreamweaver CS4 on a Mac, without turning the text into links?
A: Although the Mac version of Dreamweaver does not support the direct insertion of Word files, you can copy and paste from Word into Dreamweaver (as is recommended in the tutorial for Mac users). To control how the text is formatted, go to Dreamweaver > Preferences and select the Copy/Paste category. From there, Mac users can access the same controls that Windows users get when inserting a Word file. Just remember to select the proper preference before copying and pasting from Word.
Q: Is there any way to change a nested template from a two column structure to a single column structure? As explained in the "Working with nested templates" video, it appears that the nested template must maintain the same basic structure as the main template. If one is using a template with a header, footer, main content area, and sidebar, is it possible to create a template without the sidebar?
A: Making these changes is possible, and there are a few ways of doing it. First, one could make the sidebar an optional region. For info on that, check out the “Creating optional regions” video of the Dreamweaver CS5 Essential Training title. (The technique works the same in CS5 and CS4).

However, the layout also needs to be changed (switched from a two column to a single column layout, for example), and that can be a bit tougher. Since layout is controlled through CSS, usually what's done is this: There is usually a class assigned to a top level tag (such as the body or the wrapper div) that control the other areas on the page. For pages without the sidebar, one could apply the template, not add the optional sidebar region, and have the class on the body tag be an editable attribute. Then, a class such as "singleCol" or "multiCol" could be assigned, based on which layout is needed.

The other approach is to use multiple templates, but the problem there is how to update them. Nested templates could be used to build a version with the sidebar, which would help ease the updating process, but, overall, the recommend method is to use the first approach or a combination of the two.
Q: Upon selecting Edit in Flash for a SWF in Dreamweaver CS4, an error message appears that says:

Unable to launch Macintosh HD: Applications:Adobe Extension Manager CS4:Adobe Flash CS4:Adobe Flash CS4.app. Please be sure that this application exists and that there is enough memory to run it.

Ctrl-clicking the SWF in the Design view and choosing Go to source file from the contextual menu and then selecting the FLA file from the list will enable the Edit button, but the file opens in Flash independently and not via Dreamweaver. What is causing this error?
A: Unfortunately, Dreamweaver's round-trip workflow is somewhat buggy, so there are several possible explanations.

 The lynda.com exercise files are not structured the same way a normal website would be, so redefining sites and moving files around as you do from lesson to lesson can cause problems.

Usually the Edit button will be grayed out if Dreamweaver doesn't know where the original FLA file is located (as can happen when they are in different directories). This can also happen if the FLA and the SWF have different names. ("file1.fla" publishs "mymovie.swf" for example.)

One possible solution is to set the source in the Properties Inspector. Another is to re-establish the link to the source file via the point-to-file icon. If the problem persists, browse for the FLA file if prompted by Dreamweaver. This should establish a link between the SWF and the FLA file.

Unlike the PSD integration, Dreamweaver does not import the FLA file, but the SWF, so Dreamweaver has to be able to "see" the source FLA file in order to make the round-tripping work. As the files are moved around between multiple programs, they go through several rounds of compression. This alone can cause features like this to result in an error.

To test if the problem is with the system and not the software, delete the SWF file from the page, re-import it using the Insert panel or menu, and then save the page. This should clear out any caching problems with the old SWF file and re-establish the link.
Q: I am unable to recreate the exercise enabling me to make new CSS rules for the body and header text, as shown in "Understanding Element Selectors." The headers don't update after I enter the H1 rule.
A: The most likely explanation is that the wrong option is selected in the CSS Rule Definition dialog. Make sure the pull-down menu says Tag for the selector type, not Compound, which it tends to default to. That should resolve the problem, and all for new CSS styles to be created. 

 
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

* Estimated file size

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 CS4 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 ?

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 preferences from 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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

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.