Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Creative tools for business
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / Dreamweaver Developer Center /

Managing websites with multiple layouts

by Adrian Senior

Adrian Senior
  • www.webade.co.uk
  • www.communitymx.com
  • www.ukcsstraining.co.uk

Content

  • Using multiple layout options
  • Creating your first layout style

Created

14 May 2007

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
CSS design Dreamweaver CS3 Dreamweaver CS4 website

Requirements

Prerequisite knowledge

To complete this tutorial, you should have a basic understanding of HTML and Dreamweaver.

User level

Intermediate

Required products

  • Dreamweaver (Download trial)

Sample files

  • multiple layouts.zip (8 KB)

Note: This tutorial was written for Dreamweaver CS3. Although Dreamweaver CS4 adds new CSS functionality (revised Property inspector, Code inspector, related files), the CSS panel in Dreamweaver CS4 has not changed, and you should still be able to follow this tutorial using Dreamweaver CS4 or Dreamweaver CS5.

If you have purchased or installed the Dreamweaver CS3 trial, then you can't have helped but be impressed by the new standards-compliant CSS starter pages. To have the ability to create CSS layouts in what amounts to no more than a few clicks is a great time-saving feature: no more bug hunting, no more hours of hair pulling. The CSS layouts are simple and easy to use and provide you with a great base from which you can create your own design style.

As easy as the CSS layouts are to work with, you may have missed one of the great features of these starter pages: the ability quickly and easily to mix and match the different layouts available into a single CSS file. This tutorial will teach you exactly how you can utilize the new CSS features to implement this type of design.

Using multiple layout options

Multiple layouts in a single CSS file are achieved by the clever use of descendant selectors to isolate one CSS rule from another. The parent element of these descendant selectors is set on the body tag in the form of a class; it is this class that controls when a CSS rule is applied and when it isn't. Take a look at one particular rule that appears in the layouts you will utilize in this tutorial.

.oneColLiqCtrHdr #mainContent { padding: 0 20px; background: #FFFFFF; }

Listing 1. The #mainContent descendant selector

Listing 1 above, is, as I'm sure you know, a descendant selector. A descendant selector consists of two or more selectors (in this case you have a class and an ID selector), and the values within the CSS rule will only be applied when #mainContent is a child of the .oneColLiqCtrHdr class.

Note: Each of the classes used in the descendant selectors is an abbreviation of the layout type of the page.

The element to which the #mainContent rule refers is the main content container within your design; the class in the descendant selector would be applied to the body element. This means that only when the body element (All such descendant selectors in the CSS layouts have the class set against the body) has a class of .oneColLiqCtrHdr set against it will the values for the #mainContent div be applied.

.twoColLiqRtHdr #mainContent { margin: 0 26% 0 10px; }

Listing 2. A different version of the #mainContent descendant selector

The descendant selector in Listing 2 works in exactly the same way as explained earlier. However, the name of the class has changed, and the properties and values for the #mainContent rule have also changed. In this instance the #mainContent values are allowing for a right-hand column to sit next to the mainContent area. The space to the right of the mainContent area where the column will sit is provided by the right margin value of 26%.

By using this technique you can easily change values on any given element to accommodate added or removed elements that may appear around it from page to page. For a deeper explanation of descendant selectors, please read this article I wrote: Defining and using Descendant Selectors. In short, the descendant selector enables you to manipulate your page layout easily by simply changing the class against the body. Sound complicated? Well, it isn't, really; but you will be delighted to hear that Dreamweaver CS3 controls all this for you automatically without you ever having to look at a descendant selector, never mind edit one!

Creating your first layout style

You'll begin by creating your first page for your design; this page will be the "1 column liquid, centered, header and footer" page as shown in Figure 1. Make sure you leave the option selected to add the CSS to the head of your document. You will create a CSS file and move your CSS rules to that file a little later.

Selecting the first layout page type
Figure 1. Selecting the first layout page type

There's no need to save your page as yet; you can go right on and create your second layout. Select the options as shown in Figure 2.

Selecting your second layout page type
Figure 2. Selecting your second layout page type

Finally, you can now create your third type of page layout (see Figure 3).

Selecting your third layout page type
Figure 3. Selecting your third layout page type

You should now have three unsaved pages, one of each of the following:

  • One-column liquid centered header and footer
  • Two-column liquid, right sidebar, header and footer
  • Three-column liquid, header and footer

Before you go any further, you should create a local site definition. Within the root of that local site definition, create a folder called CssFiles. If you're unsure how to create a site definition, please read the following TechNote 14028: How to define a site in Dreamweaver.

With your site definition and your CssFiles folder created, you can now save your pages to the root of your newly created site definition. For the sake of ease, save your one-column page as 1.html, your two-column page as 2.html and your three-column page as 3.html.

With your pages saved, it is now time to build the CSS file.

Watch the movie: Building the CSS file

Alternatively you can complete the following steps. First, export the styles from 1.html:

  1. Switch to your 1.html file in code view.
  2. Highlight all CSS rules in the head of your document between your style tags. Take care not to include the comments.
  3. Right-click in the embedded style sheet.
  4. Select CSS Styles from the context menu.
  5. From the pop-up menu, select Move CSS Rules… The Move To External Style Sheet dialog box opens.
  6. Select the "A new style sheet" option.
  7. Click OK.
  8. Navigate to your CssFiles folder.
  9. Type MyStyleSheet into the File name: box.
  10. Click Save and the dialog box closes.
  11. Highlight the style tags in your 1.html page and delete them. Notice your new style sheet is automatically linked.
  12. Save your work.

Next, export the styles from 2.html:

  1. Switch to 2.html.
  2. Highlight all the rules in your embedded style sheet, taking care not to include the comments and style tags.
  3. Right-click in the embedded style sheet.
  4. Select CSS Styles from the context menu.
  5. From the pop-up menu, select Move CSS Rules… The Move To External Style Sheet dialog box opens.
  6. Click Browse.
  7. Navigate to your CSS file, select it and click OK. The dialog box closes and returns to your Move To External Style Sheet dialog box.
  8. Click OK. The Rule with Same Name Exists dialog box opens.
  9. Click No to each rule that is shown to prevent exporting duplicate rules. The dialog closes.
  10. In 2.html, highlight and delete the style tags and any unexported rules.
  11. Save your work.

Finally, export the styles from 3.html. Follow the same steps you did for 2.html.

You have now exported the CSS styles from each of your pages into a single CSS file. Each of your pages will only use the descendant selectors that match their structure, thus enabling you to work easily with multiple page types in a single file.

Whenever you need to create a new page, you can now select the page structure you need from the CSS layouts and link directly to your existing CSS file by opting for Link to External File in the Layout CSS: pop-up menu (see Figure 4) and then clicking the link in the Attach CSS File: box and navigating to your CSS file.

Linking to a new page to an existing style sheet
Figure 4. Linking to a new page to an existing style sheet

Now that you have used Dreamweaver’s new CSS functions and particularly the “Rule with Same Name Exists “ function we can explore a little further. While your style sheet will work fine as it is it does contain some redundancy, by redundancy I mean duplicated rules that aren’t really necessary to render the page correctly.

As an example, the header div will always be the same in each of our pages no matter whether those pages are of a one, two or three column structure. With this in mind it is clear that we don’t need to have three different rules for the header div, or indeed for the rule you have set against the header h1 element.

To tidy up your style sheet you can remove the class from the front of one of your #header rules and do the same for one of your #header h1 rules, all remaining rules of this type can be safely deleted.

.oneColLiqCtrHdr #header { background: #DDDDDD; padding: 0 10px 0 20px; }

Listing 3. An example of an existing header rule

In listing 3 above you can see that your rule is a descendant selector, this isn’t necessary as the header div will be the same on all pages, you can remove the class from the selector and just refer to this rule as #header.

#header { background: #DDDDDD; padding: 0 10px 0 20px; }

Listing 4. A modified header rule

In listing 4 you can see the modified rule, once you have modified one instance of your #header and #header h1 rules all remaining rules that reference these elements can be safely deleted. This also applies to the #footer and #footer p rules; you only to need to have one generic rule for each and the rest can be removed.

The area of concern is the #mainContent div, and the #sidebar1 and #sidebar2 rules. These elements will vary in their dimensions depending on the amount of columns in any given page; you will need to ensure that you keep these rules intact to maintain your layouts structure. It is of course here that the descendant selector becomes important, the descendant selector ensures that the correct values are supplied to the browser in order to render your page correctly.

If you’re unsure of which rules you can safely delete it is a good practice to open the page you’re working on in a browser window and refresh the page each time you make an edit in the style sheet.

Conclusion

The completed files for this tutorial are available within the Zip archive referenced at the start. I hope you find this tutorial helpful and that it makes it easier for you to manage multiple layouts within a single website.

Where to go from here

For more resources on the page layouts in Dreamweaver CS3, see the following two articles. Also check out the CSS page on the Dreamweaver Developer Center for more tutorials and articles covering CSS in Dreamweaver CS3.

  • Understanding the new Dreamweaver CS3 CSS Layouts
  • CSS page layout basics

More Like This

  • Turning a design into HTML and CSS using the Fireworks to Dreamweaver workflow – Part 2: Modifying the HTML and CSS
  • Working with Drupal in Dreamweaver CS5
  • Styling and inserting a Spry Menu Bar 2.0 widget with the Adobe Widget Browser
  • Turning a design into HTML and CSS using the Fireworks to Dreamweaver workflow – Part 1: Exporting the design
  • HTML5 and CSS3 in Dreamweaver CS5.5 – Part 3: Using CSS media queries to target different screen resolutions
  • HTML5 and CSS3 in Dreamweaver CS5.5 – Part 2: Styling the web page
  • Understanding Spry basics
  • Getting to know your CSS selectors – Part 1: CSS2.1 and attribute selectors
  • Excerpt: Bring Your Web Design to Life
  • Getting to know your CSS selectors – Part 2: CSS3 pseudo-classes and pseudo-elements

Tutorials and samples

Tutorials

  • Understanding HTML5 semantics: Changed and absent elements
  • Mobile app with PhoneGap: Submitting to the Apple App Store
  • PhoneGap and Dreamweaver: Releasing on iOS
  • Mobile app with PhoneGap: Submitting to Android Market

Samples

  • Responsive design with jQuery marquee
  • Customizable starter design for jQuery Mobile
  • Customizable starter design for HTML5 video
  • Customizable starter design for multiscreen development

Dreamweaver user forum

More
04/23/2012 Resolution/Compatibility/liquid layout
04/20/2012 using local/testing server with cs5 inserting images look fine in the split screen but do not show
04/18/2012 Ap Div help
04/23/2012 Updating

Dreamweaver Cookbook

More
11/07/2011 Simple social networking share buttons
09/20/2011 Registration form that will generate email for registrant to validate
08/21/2011 Spry Accordion - Vertical Text - Auto Start on Page Load - Mouse Over Pause
08/17/2011 Using cfdump anywhere you like

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement