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

Clearing and containing floats


Dreamweaver CS4 Essential Training

with James Williamson

Video: Clearing and containing floats

There will be times when creating float-based layouts that you want the floated elements to no longer affect the elements to follow them. In our own layout, for example, the mainContent region and the Sidebar are using floats to achieve this two column layout. We don't want or need the footer to be overlapped by our floated elements, like it is here. Towards that end, we'll apply a clear to our layout. Clearing floats is an essential technique for achieving reliable float-based layouts. It's your way of saying that's it, those floated elements don't float any element past this point.
Expand all | Collapse all
  1. 1m 52s
    1. Welcome
      1m 13s
    2. Using the exercise files
  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

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
James Williamson

Clearing and containing floats

There will be times when creating float-based layouts that you want the floated elements to no longer affect the elements to follow them. In our own layout, for example, the mainContent region and the Sidebar are using floats to achieve this two column layout. We don't want or need the footer to be overlapped by our floated elements, like it is here. Towards that end, we'll apply a clear to our layout. Clearing floats is an essential technique for achieving reliable float-based layouts. It's your way of saying that's it, those floated elements don't float any element past this point.

The clear property has three values: left, right and both. By clearing to the left or to the right, you're essentially saying nothing can float to the left or right of the clear element. A clear value of both says that, no element may float to clear the element, whether to the right or the left. Once floats are cleared, normal document flow continues and cleared elements will continue to push down and response to elements above them, even the floated elements. To finish this layout, we'll clear the floated element, which will move it down below our floated elements into the desired location. So back here in Dreamweaver and I have the index.html page opened up from the 10_05 folder. Now I'm going to go over to my main_layout. css and find the #footer selector and I'm just going to go ahead and add the clear, both property to it. Since this sidebar floats to the right and the mainContent floats to the left.

Now, if I do a Save All and test that in my browser, Ah! Success. Notice the footer is pushing down below the mainContent and the sidebar region and normal document flow is being restored. If I increase the height of either the mainContent or the sidebar, the footer would push down with it and let's check that out. I'm going to go to the mainContent region and I'm going to take the height and I want to increase that height to 500 pixels instead of 300. We'll do a Save All and Preview that on our browser. So, notice that the clear property is causing the footer to continually to be pushed down by these other elements, regardless of which one is taller and there is our finished layout.

So we use clearing to complete our layout and force the footer down below the floated elements, but clearing can have other uses as well, such as containing floats. First, it occur within other elements can cause the containing element to collapse. The floated element is removed from normal document flow, so the parent considers itself empty and collapse it in and on itself. Take our interior content here. This image, and paragraph are contained within another div tag. If we were to float this image, the container would no longer see the image as being part of its contents, so its height would collapse down below the height of the actual image.

Let's illustrate that and then what we can do to fix that, by clearing a contain float. Let's go back in the Dreamweaver and let's try another selector. So I'm going to select the # innerContent selector and choose New CSS Rule and I'm just going to do #selector of # innerContent img. So we are going to float the image inside of that, go ahead and Click OK. Click on the Box Category and choose Float, left, Click OK. Now, you can dramatically see that the container element is collapsing. It only contains the paragraph now and not the image anymore because remember the image is removed from normal document flow. If I were to preview that in my browser, you can see the container collapsing. How do we keep that from happening? Well, we do that by clearing the float inside the container element, there are actually two ways to do that.

Notice that we have a class style called clear and it has a clear both property to it. So if I were to comment for example, and create another paragraph underneath it, choose this empty paragraph and give it a Class of clear; that would have the clear both property applied to it and if I Save this and Preview that in my browser, I can see that now we are containing this floated element. There is another way to contain floats as well. If I grab this empty paragraph and deleted it, my float collapses again. But if I take the parent element; in this case the #innerContent and I give it a float property as well and I'll go ahead and float that to the left, that also forces it to contain any floats inside of it. So I'll do a Save All and Preview that in my browser.

So we have learned it to restore normal document flow and to prevent elements from continuing to float, we use the clear property. If we have floated elements inside containers, we'll occasionally have to contain the floated elements by either clearing at a strategic point inside the container or by floating the container itself. If you become familiar with these techniques, you'll understand how 90% of all CSS-based layouts online are created.

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


You have completed Dreamweaver CS4 Essential Training.

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

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:

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

Start your FREE 10-day trial

Begin learning software, business, and creative skills—anytime,
anywhere—with video instruction from recognized industry experts. provides
Unlimited access to over 4,000 courses—more than 100,000 video tutorials
Expert-led instruction
On-the-go learning. Watch from your computer, tablet, or mobile device. Switch back and forth as you choose.
Start Your FREE Trial Now

A trusted source for knowledge.


We provide training to more than 4 million people, and our members tell us that helps them stay ahead of software updates, pick up brand-new skills, switch careers, land promotions, and explore new hobbies. What can we help you do?

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about 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

Sign up and receive emails about 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.