Dreamweaver Tutorials

Get Started in Dreamweaver: Define a new or existing Web site

Find out how easy it is to register a domain name

Designing with CSS

When using CSS, What Selector Type Should You Use?

Customize a CSS Layout in Dreamweaver CS3

Align Images with CSS in Dreamweaver

Create a Navigation Bar with an Unordered List and CSS

Compare Layout Options: Tables, Layers, or CSS

Make your site accessible to all your visitors

Where to learn advanced CSS tips and tricks

AJAX and Spry

Create Collapsible Panels with AJAX using Spry

Adding a Drop-Down Menu with Ajax using the Spry features in Dreamweaver CS3

Working with Multimedia

Insert a Flash File using Dreamweaver CS3

Insert a Flash Video File

Convert Video into Flash with the Flash Video Encoder

Using Behaviors

Use Swap Image Behavior to Create Multiple Rollovers

Swap Image Behavior

Use a Behavior to Launch a New Browser Window

Add new features to Dreamweaver with Extensions

Connect an HTML Form to a Script in Dreamweaver

More Resources

Cool online tools you can use on your Web site

Comparing Web design programs and technologies

Video Training

Discover how training videos make learning fun and easy!

Dreamweaver FAQ

Get answers to your questions, and maybe even a few you hadn't thought of yet, in the Dreamweaver FAQ

Total Training Videos

 

Partners and sponsors

Total Training Online Software Training - Try it Now Get Free Access

Dreamweaver FAQ

Get answers to your questions, and maybe even a few you hadn't thought of yet, in the Dreamweaver FAQ.

Dreamweaver CS3 advertisement CS3-DW-125x125

Free Greeting Card, Expires 2-27-07

Trusted by over 7 million customers!

Total Training

IX Web Hosting ad

If you're in town, stop by our Dreamweaver training Chicago and get lessons on other software like Access training too. The Dreamweaver training program helps you make successful websites quickly!

Create a Custom Centered, 2-Column Layout with CSS in Adobe Dreamweaver

CSS layoutStep-by-step instructions for creating a two-column, centered design using Div tags and CSS in Dreamweaver 8 (can be used with Dreamweaver CS3 or MX 2004).

 

Partners and sponsors

Order Your Dreamweaver Training Video Today!

STEP 1 Plan Your Design in Advance
I created this illustration so you see how the div tags in this page are positioned. Because div tags are invisible in a browser, it's difficult to see how they work in a completed page. And, until you create styles to position them, divs simply span vertically across the page. In this image, you see the structure that I want in my final design. Notice that I created one div that surrounds all of the other divs and called it "container." All the other divs are contained within that div and I'll use that div to center the design. (Note: You can name divs anything you like, as long as you don't use spaces or special characters.)

If you want to see what this page will look like when the design is complete, follow this link to the completed HTML file with images and text in place.

tutorial screenshot

STEP 2 Create a New Page and Set Page Properties
Create a new Web Site or open an existing one and choose File>New> HTML to create a new page. Choose Modify>Page Properties to set options for the entire page and Dreamweaver will automatically create the corresponding CSS styles for the body tag. In the Appearance category, you can set the font face, size, and color. In this example, I chose Arial, Helvetica, san serif; set the size to Small, and left the text color set to the default black. I also set the margins to 0 so that my design will be flush against the top and left side of the page.

tutorial screenshot

STEP 3 Insert Divs for Each Section
This step can get a bit tricky, but the goal is simple--to insert a div tag for each section of the page. To do so, click the Div button in the Common insert bar at the top of the page and enter a name in the ID field for each div. When you click OK, the div will automatically span across the top of the page. The trick is to make sure that you create the divs in order and that all of the section divs are placed inside the container div. I find it easier to ensure this if I have the design area set to Split so that I can see the code while I work.

tutorial screenshot

STEP 4 Add Content to Divs
Although you can create the corresponding styles as you create the divs, I also find it easier to get all of my divs and content in place before I create the styles to position them. As you can see in this image, I've inserted images and text into each of the divs that will hold my content. You can add content to divs as you would add content anywhere else on a page. I used copy and paste to insert text from a word document, and the Inset Image icon in the Common insert bar to insert the images.

tutorial screenshot


STEP 5 Create a Style for the Container Div
To create a new style for the container div, choose Text > CSS Styles > New. In the New CSS Rule dialog, select the Advanced radio button and enter a name (note, your style names must exactly match your div names). For each of these divs, create an ID style, which requires typing a pound sign at the beginning of the name. ID styles can only be used once per page and are ideal for positioning divs. (Note that you can let divs span the entire page so that they auto-adjust to fill the browser window, but I've chosen to use a fixed width for this design.)

tutorial screenshot

STEP 6 Create New Styles in an External Style Sheet
If you choose the radio button next to This document only, your style will be saved in the head area of your HTML file. If you choose Define in, you can save your style in an external style sheet. The advantage is that you can attach the same external style sheet to any page in your web site, a more efficient option than recreating styles for every page, and an easy way to make global updates later. To create a new external style sheet as you create a new style, choose the radio button next to Define in and click OK. In the Save Style Sheet File dialog, enter a name for the external style sheet.

tutorial screenshot

STEP 7 The "Trick" to Centering a Div
In the CSS Rules Definition dialog, chose the Box category and set the width for you container. In this example, I set it to 785 pixels (a safe width for display on an 800 by 600 resolution monitor). Now for the not-so-intuitive trick you need to center the div. Notice that I've set the left and right margins to auto and unchecked the Same for All box. This causes the browser to automatically position the div in the middle of the page by creating equal sized margins on the left and right sides of the div.

tutorial screenshot

STEP 8 Do the Math
The trick to this step is that you need to calculate how wide to set your story and sidebar divs. As you see in this illustration, if the #container div is 785 pixels, and we want the #story div to be 475 pixels, plus we want 10 pixels of padding around each of our divs so our text and images don't bump into each other, that means we’ve taken up 10+10 =20 pixels per div in padding. Since we have two divs that’s 40 pixels of padding total. If we add that to 475, we get 515. Now subtract that from 785 and I have 270 pixels left for the sidebar. (Yes, you can use a calculator).

tutorial screenshot

STEP 9 Create a Style for the Story Div
Choose Text > CSS Styles > New. In the New CSS Rule dialog, select the Advanced radio button and enter a name. In this case, I've named it #story. Since I've already created the external style sheet, I can simple select it from the drop-down list next to Define In and click OK. In the CSS Rule definition dialog, choose the Box Category and set the width to 475 pixels, the Float to right, and padding to 10, leaving the Same for All box checked. Then select the Background category and set the background color. (In this example, I set it to white because I'm going to add a gray background color to the entire page later.)

tutorial screenshot

STEP 10 Create a Style for the Sidebar Div
Choose Text > CSS Styles > New. In the New CSS Rule dialog, select the Advanced radio button and enter #sidebar. Again, choose the external style sheet from drop-down list next to Define In and click OK. In the CSS Rule definition dialog, choose the Box Category, set the width to 270 pixels, set the Float to left, and set padding to 10, leaving the Same for All box checked. Then select the Background category to set the background color of the div. In this case, I've used a golden color to better define the sidebar.

tutorial screenshot

STEP 11 Create Styles for the Navbar and Footer
Choose Text > CSS Styles > New. In the New CSS Rule dialog, select the Advanced radio button and enter #navbar. Choose the external style sheet from drop-down list next to Define In and click OK. In the CSS Rule definition dialog, choose the Box Category, set the height to 20 pixels, set padding to 10, and check the Same for All box. Since I want the navbar to span the full width of the design, I can leave the width blank. Select the Background category to set the background color, and select the Type category to set the text color and style. Repeat these steps to create an identical style for the footer.

tutorial screenshot

STEP 12 Use the Clear Div Trick to Keep the Divs from Overlapping
If your story and sidebar are not exactly the same length, floating them left and right like this will cause the footer to wrap up under the shorter of the two divs. This is a common problem in CSS layouts, but there is an easy fix. You can create a style that clears everything to the left and right of a div. To do so, choose Text > CSS Styles > New and select the Class radio button. Class styles can be applied multiple times on the same page and must begin with a period. In the Box Category of the CSS Rule Definition dialog, choose Clear and select Both from the drop down.

tutorial screenshot

STEP 13 Apply the Clear Class Style
Unlike ID styles which are automatically applied to divs with the same name, you'll need to apply the Clear style to the div. To do so, click to select the div (I find it easiest to select divs using the tag selector in the bottom left of the design area). Then use the CSS drop-down in the Properties inspector and select the Clear style to apply it. As you see in this example, the footer div drops to the bottom of the sidebar and story divs when the clear style is applied.

tutorial screenshot

STEP 14 Add a Few More Styles for Images and Navigation Elements
To achieve the final design you see here, I used Page Properties again to set the background color for the entire page to a dark grey. To align the images so the text wraps around them, I created class styles with the float set to left and right respectively, and added 10 pixels of margin to keep the images from bumping up against the text. I also created a rather complex style for the links in the navbar and footer by redefining the Anchor, Unordered List, and List HTML tags. You'll find tutorials for all of these tricks at layersmagazine.com.

tutorial screenshot

This article by Janine Warner was created for Layers Magazine and published in the Jan/Feb. issue (2006/2007).

Return to Dreamweaver Training Center at DigitalFamily.com.

Partners and sponsors

Shutterfly.com