Adobe Dreamweaver CS5 – Part 6: Publishing your website


Adobe Dreamweaver CS4 logo

Image via Wikipedia

Welcome to the sixth and final part of this article series on creating your first website. This tutorial shows you how to set up a remote site in Dreamweaver. A remote site is usually a web server on a remote computer that holds copies of your local files. Users access the remote site when they view your pages in a browser.

This tutorial presents a very broad example of connecting to a remote server. It contains troubleshooting hints, but much depends on how your remote server is configured. When in doubt, consult your hosting company’s help desk or your system administrator.

Learn about remote sites

After you create a website, the next step is to publish it by uploading the files to a remote server. This is where you store your files for testing, production, collaboration, and publication (depending on your environment).

Before you can proceed, you must have access to a remote web server—such as a hosting company’s server, a server owned by the client you’re working for, or an intranet server within your company. Also, some Internet Service Providers (ISPs) provide access to free web space as part of your contract for internet connection. If you don’t have access to such a server, contact your ISP, your client, your system administrator, or one of the many hosting companies that provide web hosting packages. Some hosting packages are free, but usually insert advertisements into your site. An advertisement-free package can cost as little as a few dollars a month.

Alternatively, you can run a testing server on your local computer or network. For more information, see Setting up a local testing server in Dreamweaver CS5. The rest of this article concentrates on connecting to a remote server using FTP (file transfer protocol) or SFTP (secure file transfer protocol).

You also need to have a local site defined before you proceed. For more information, see Part 1 of this tutorial series,Setting up your site and project files.

Note: For more information about Dreamweaver sites, see Setting up a Dreamweaver site in Dreamweaver Help.

Define a remote server

Dreamweaver site management is based on the principle that your local files are an exact duplicate of your live site on the internet. So, index.html in your check_cs5 folder becomes the front page of your remote site. If you already have a live website that you don’t want to overwrite, use your site’s control panel to create a folder called check_cs5 where you can upload the Check Magazine files.

  1. In Dreamweaver, select Site > Manage Sites.
  2. In the Manage Sites dialog box, select the Check Magazine site.If you did not define the Check Magazine site, create a local folder for the site before you proceed. For more information, see Part 1 of this tutorial series, Setting up your site and project files.
  3. Click Edit.
  4. In the Site Setup dialog box, click Servers to open the panel where you add your server definitions (see Figure 1).

The Servers panel in the Site Setup dialog box.

Figure 1. The Servers panel in the Site Setup dialog box.

Dreamweaver CS5 allows you to set up multiple server definitions for both remote and testing servers. However, only one of each type can be active at any given time.

  1. Click the plus button at the bottom left of the panel to add the remote server definition. This opens a new panel for you to enter the server details (see Figure 2).

The panel where you enter the basic server details.

Figure 2. The panel where you enter the basic server details.

  1. In the Server Name text box, type a name for the server. This is used internally by Dreamweaver to identify the server, so you can choose any name you like. For example, you might want to create a definition for a server where you upload files for a client’s approval, and a different server for the live site. If you have only the one server, call it Remote Server.
  1. From the pop-up menu Connect using, select the method you want to use to connect to the server.The most common methods for connecting to a server on the Internet are FTP and SFTP. If you aren’t sure which to select, ask your hosting company or the server system administrator.
  2. The following options apply to both FTP and SFTP:
    • Enter the server’s FTP address (for example, ftp.yourdomain.com).
    • Enter your user name and password in the appropriate text boxes.
    • Click Test to test your connection.

    If the connection is unsuccessful, verify that you have the correct username and password. Passwords are usually case-sensitive, so make sure that Caps Lock is not turned on. If you selected SFTP, try FTP instead. If that doesn’t solve the problem, consult the troubleshooting section further down this page.

  3. The value that you need to enter in Root Directory is where many people go wrong, and it’s difficult to give precise instructions because hosting companies and server administrators have different policies.As I said earlier, Dreamweaver site management is based on the principle that your local files are an exact duplicate of your live site on the Internet. The value of Root Directory should be the path you need to enter after logging into your server to get to the folder where you want to install index.html.
    • If you want the Check Magazine home page to be the front page of your website, then this needs to be the path to the remote server’s site root. On some servers, it’s public_html. Others might use wwwwwwroot, or even nothing at all. On my remote server, it needs to be /home/username/public_html. If in doubt, ask your hosting company or server administrator.
    • If you want the Check Magazine home page to be in a subfolder called check_cs5, you need to enter the path to that folder. For example, on my server, it would be /home/username/public_html/check_cs5.
  4. The Web URL text box should contain the URL for the folder that you defined as the Root Directory. For example,http://www.example.com/ or http://www.example.com/check_cs5/. Dreamweaver might have tried to guess the correct value, but it’s only a guess. Do not accept the default value without checking it carefully.

Your settings should look similar to Figure 3.

Settings for connecting to a remote server by SFTP.

Figure 3. Settings for connecting to a remote server by SFTP.

  1. Click the Advanced button at the top of the panel to display the advanced options (see Figure 4).

Advanced options for a remote server.

Figure 4. Advanced options for a remote server.

  1. In most circumstances, you should leave these options at their default settings.
    • Maintain synchronization information is selected by default. This keeps track of when the files on your remote server were last updated, and allows you to use the Site Synchronization feature (see Synchronize the files on your local and remote sites in Dreamweaver Help).
    • Automatically upload files to the server on Save should rarely, if ever, be used because it overwrites your live files. If you make a mistake, it’s immediately displayed on your remote site for all the world to see.
    • Enable file check-out is for use in a team environment. It allows only one person at a time to edit a page (seeChecking in and checking out files in Dreamweaver Help).
  2. Click Save to register your server definition. This returns you to the Servers panel of the Site Setup dialog box, where your server definition is now listed (see Figure 5).

The remote server is now registered in the Site Setup dialog box.

Figure 5. The remote server is now registered in the Site Setup dialog box.

Dreamweaver selects the Remote checkbox automatically.

The icons at the bottom of the Servers panel allow you to add another server, or to delete, edit, or make a copy of the selected server definition. Making a copy is useful if you need to change only a few details to connect to a different server.

  1. Click Save to close the Site Setup dialog box, and then click Done to close the Manage Sites dialog box.

Upload your local files

You can now upload your files from your local folder to the remote web server to make your pages publicly accessible.

  1. In the Files panel (Window > Files), select the site’s local root folder (check_cs5).Note: In the Files panel, the local root folder actually begins with “Site – Check Magazine” because that’s the name of the site. If you hover the cursor over that title, Dreamweaver shows you the full path to the check_cs5 folder.
  2. Click the Put Files (up arrow) icon in the Files panel toolbar (see Figure 6).

Put files on the server.

Figure 6. Put files on the server.

  1. When Dreamweaver asks if you want to put the entire site, click OK.Dreamweaver copies all of the files to the remote folder you defined in the previous section. This operation may take some time, as Dreamweaver must connect to the remote server and then upload all the files.

    Note: Normally, you select the local root folder and upload the entire site only the first time you upload. Afterwards, you can upload only the files you’ve changed.

  2. Open your remote site in a browser to make sure all of the files uploaded correctly. Congratulations, you have a site online!

(Optional) Troubleshoot the remote server setup

A web server can be configured in many ways. The following list provides information about some common issues you may encounter in setting up a remote server and how to resolve them:

  • The Dreamweaver FTP implementation may not work properly with certain proxy servers, multilevel firewalls, and other forms of indirect server access.
  • In the panel where you set the basic options for the remote server, set the “Connect using” pop-up menu to FTP, and click the triangle at the bottom of the panel to reveal the More Options section (see Figure 7).

The More Options section can help solve FTP connection problems.

Figure 7. The More Options section can help solve FTP connection problems.

  • Use Passive FTP often solves connection problems caused by a software firewall.
  • Use IPV6 Transfer Mode should be used only if your remote server supports the newer IPv6 protocol (check with your hosting company or server administrator).
  • If you need to connect through a proxy server, select the Use Proxy check box, and click the Preferences link to set up the proxy details.
  • The other two options are self-explanatory.
  • If you still have problems with FTP access, contact your hosting company or system administrator for help.
  • For the Dreamweaver FTP implementation, you must connect to the remote system’s root folder. (In many applications, you can connect to any remote directory, and then navigate through the remote file system to find the directory you want.) Be sure that you indicate the remote system’s root folder (or the check_cs5 subfolder) as the Root Directory. If you have problems connecting, and you’ve specified the host directory using a single slash (/), you might need to specify a relative path from the directory you are connecting to and the remote root folder. For example, if the remote root folder is a higher-level directory, you may need to use ../../ to specify the host directory.
  • File and folder names that contain spaces and special characters often cause problems when transferred to a remote site. Use underscores in place of spaces, and avoid special characters—colons (:), slashes (/), periods (.), and apostrophes (‘) are not permitted in file or folder names.
  • Many servers use symbolic links (Unix), shortcuts (Windows), or aliases (Macintosh) to connect a folder on one part of the server’s disk with another folder elsewhere. For example, the public_html subdirectory of your home directory on the server may really be a link to another part of the server entirely. In most cases, such aliases have no effect on your ability to connect to the appropriate folder or directory; however, if you can connect to one part of the server but not to another, there may be an alias discrepancy.
  • If you encounter an error message such as “cannot put file,” your remote folder may be out of space. For more information, look at the FTP log.

Note: In general, when you encounter a problem with an FTP transfer, examine the FTP log by selecting Site > Advanced > FTP Log. For more information, see the extensive tech note on FTP troubleshooting on the Adobe website.

Adobe Dreamweaver CS5 – Part 4: Adding the main image text


Adobe Dreamweaver CS4 logo

Image via Wikipedia

Welcome to Part 4 of this tutorial series on creating your first website. This tutorial shows you how to add text to the main image area of the index page for Check Magazine, a fictional publication, using a combination of relative and absolute positioning. The tutorial also shows you how to use CSS to format the text.

Locate your files and review your task

In this tutorial, you’ll begin with the CSS layout (index.html) you added content to in Part 3, Adding content to pages. If you did not complete that tutorial, you must complete it before proceeding, or downloadfirst_website_pt3_completed.zip (474 KB). If you haven’t completed Part 1, Setting up your site and project files, you will need to complete that tutorial as well.

Your task in this tutorial is to add a block of text to the main image area of the Check Magazine home page. You’ll also learn how to format the text using CSS. Figure 1 shows what the main image area will look like in a browser after you’ve added the text.

The main image area of the Check Magazine home page with added text.

Figure 1. The main image area of the Check Magazine home page with added text.

Basically what you’ll do to accomplish this task is add a div with text to the main image area, format the text, and lastly, position the div.

Add the div tag and text

Although the main_image div looks as though it’s filled with a large image, there’s actually nothing inside the div. The image is simply the background. If you look at the original design comp again, you’ll see that to finish the page, you need to add a block of text at the bottom right of the div. You also need to add a menu bar, but you’ll tackle that in Part 5. First, let’s deal with the text in the main_image div.

The text consists of two headings and a paragraph, so you need to create a div to hold them all together, and nest it inside the main_image div.

  1. In Dreamweaver, open the index.html file that you created in Part 3, Adding content to pages.
  2. The most accurate way of inserting a new div is to use the options in the Insert Div Tag dialog box. It doesn’t matter where the Insertion point is, the options enable you to insert the div accurately, as long as your page elements have IDs. All the divs in index.html have been given IDs, so it’s just a question of choosing the correct options in the dialog box.Click Insert Div Tag in the Insert panel, or select Insert >Layout Objects > Div Tag to open the Insert Div Tag dialog box.
  3. Click the down arrow of the Insert pop-up menu to reveal the options (see Figure 2).

View the options for where to insert the new div tag.

Figure 2. View the options for where to insert the new div tag.

The options available are:

  • At insertion point. The new div is inserted wherever the Insertion point currently is.
  • Before tag. The new div is inserted immediately before the specified element’s opening tag.
  • After start of tag. The new div is inserted immediately after the specified element’s opening tag.
  • Before end of tag. The new div is inserted immediately before the specified element’s closing tag.
  • After tag. The new div is inserted immediately after the specified element’s closing tag.
  • Wrap around selection. This option is displayed only when something is selected in the document window. The new div is wrapped around the selected element(s).
  1. The new div needs to be nested inside the main_image div, so it needs to go after the starting tag of main_image. Set the Insert pop-up menu to “After start of tag.” (Because the main_image div is empty, you could also use “Before end of tag” in this case.)This activates a new pop-up menu to the right of the Insert pop-up menu.
  2. Click the down arrow of the new pop-up menu to reveal its contents. It lists the <body> tag, along with all other page elements that have an ID (see Figure 3).

Select the main_image div from the list.

Figure 3. Select the main_image div from the list.

  1. Select <div id=”main_image”> from the list.
  2. Type main_text in the ID text box.
  3. Click the New CSS Rule button at the bottom of the Insert Div Tag dialog box. This opens the New CSS Rule dialog box.
  4. Dreamweaver automatically selects the correct values for Selector Type (ID) and Selector Name (#main_text).However, you need to check that Rule Definition is set to check_cs5.css. If it says “This document only,” select check_cs5.css from the Rule Definition list.
  5. Click OK to open the CSS Rule Definition dialog box, and select Background from the Category list on the left.
  6. Click the Background-color color box, and select white (#FFF), as shown in Figure 4.

Set the CSS background-color property for main_text to white.

Figure 4. Set the CSS background-color property for main_text to white.

  1. Select Box from the Category list on the left.
  2. Type 300 in the Width text box, and make sure the pop-up menu alongside is set to px (see Figure 5). This sets the width of the main_text div to 300 pixels.

Set the width of the main_text div to 300 pixels.

Figure 5. Set the width of the main_text div to 300 pixels.

  1. Click OK. This saves the new CSS rule, and brings you back to the Insert Div Tag dialog box.
  2. Click OK to close the Insert Div Tag dialog box. This inserts the main_text div with some placeholder text.
  3. Click anywhere in the Document window away from the new div to deselect the placeholder text. The main_image div should now look like Figure 6, with a 300-pixel wide, white box containing placeholder text at the top left.

The main_text div has been nested inside the main_image div.

Figure 6. The main_text div has been nested inside the main_image div.

The white background of the main_text div covers the background image, so the text can be clearly read.

  1. Now, it’s time to insert the final text. In the Files panel (Window > Files), double-click the text.txt file to open it.
  2. Select the entirety of the last block of text in the file, everything from “OPERATIVE WORDS” up to and including “. . . hiding in his bathroom.”
  3. Copy the text by selecting Edit > Copy, by right-clicking and selecting Copy from the context menu, or pressing Ctrl+C/Cmd+C.
  4. Close the text.txt file.
  5. Select the placeholder text for the main_text div, and paste the text from your clipboard by pressing Ctrl+V/Cmd+V, or selecting Edit > Paste.The text you copied from text.txt replaces the placeholder text, and the main_text div automatically expands vertically to accommodate it (see Figure 7).

The main_text div is now ready to be formatted and positioned.

Figure 7. The main_text div is now ready to be formatted and positioned.

  1. Select File > Save All Related Files to save index.html and the style sheet.

Rearrange CSS

Before showing you how to format your text, I’d like you to take a look at the CSS. As you’ve been creating rules, Dreamweaver has been adding the CSS to the external style sheet for you. However, because you’ve created the rules at different points in the page’s development, they are not necessarily in the most logical order. I like to have my CSS ordered logically so that if I want to edit the style sheet later on, I’ll have an easier time scanning and finding the rule I’m interested in.

  1. Click check_cs5.css in the Related Files toolbar to open the style sheet in Split view (see Figure 8).

The styles you have created so far.

Figure 8. The styles you have created so far.

  1. Scroll down to the bottom of the CSS file, and note that the #main_text rule is the last rule on the page. That’s because you just added it in the previous section. Also note that the body rule is third from the bottom.Because the body rule affects the entire page (corresponding to the <body> tag of the HTML document), it’s usually the first rule in the CSS file. But since you created it after you created some of the other rules, Dreamweaver placed it farther down in the file.Similarly, the #main_text rule goes hand-in-hand with the #main_image rule, and doesn’t belong at the bottom of the CSS file. In other words, if you were looking for all of the rules that affect that central section of the page, you’d want to see these two rules grouped together in the CSS file.

    Another problem is that the body and #main_text selectors (on lines 25 and 31 in Figure 8) are on the same line as the closing brace of the previous rule. This happens if you don’t leave a blank line at the bottom of the style sheet when creating a new rule manually. It doesn’t affect the way the browser handles the style rules, but untidy code is difficult to read, and could lead to mistakes. It’s better to reformat it.

    You could work directly in the CSS file, cutting and pasting until you get the file to look the way you want. However, I’m going to show you another way.

  2. Select Commands > Apply Source Formatting. Dreamweaver sweeps through the style sheet, putting rules on lines of their own, and tidying up any indenting problems.
  3. If the CSS Styles panel isn’t already open, click its tab to open it.
  4. Click the All button to make sure All mode is selected.You’ll see all of your rules listed. The order of the rules in the CSS Styles panel follows the same order as the style sheet (that is, #main_text is last, body is third from the bottom).
  5. Select the body rule and drag it to the top of the rules list, above the #container rule (see Figure 9).

Drag the body rule to the top of the rules list in the CSS Styles panel.

Figure 9. Drag the body rule to the top of the rules list in the CSS Styles panel.

  1. Look at the style sheet in Split view. The body rule has been moved above the #container rule (see Figure 10).

The body rule has been moved in the style sheet as well.

Figure 10. The body rule has been moved in the style sheet as well.

Note: Don’t worry if you see the comment text /* CSS Document */ in between the body rule and the#container rule (see line 7 in Figure 10), you can go ahead and delete it. This is just descriptive comment text that Dreamweaver adds to the file by default.

  1. Next, select the #main_text rule and drag it up the list, dropping it just below the #main_image rule, as shown in Figure 11.

Drag the #main_text rule.

Figure 11. Drag the #main_text rule.

Your rules now follow a more logical order: first comes the body rule, which governs the entire page, then the#container rule, which also governs the other rules, since all of the elements associated with those rules exist within the container div. Then come the rules associated with each element on the page, ordered as those elements appear on the page: the main image, the main text, and the columns at the bottom.

  1. Save the style sheet.

Format the text

Next you’ll format the text inside the main_text div.

  1. The index.html file should still be open in the Document window. If it isn’t, double-click its icon in the Files panel to open it.
  2. Click the Design view button so that you are no longer in Split view.
  3. Place the Insertion point after WORDS at the end of the first line in the main_text div, and press Enter (Windows) or Return (Mac OS X) to divide the text into separate paragraphs.
  4. Press the down arrow key once so that the Insertion point is before the word Stumbling, and press the Backspace key once to delete line break. This is the same technique as you used when breaking up the text you pasted in Part 3 of this tutorial series.
  5. Place the Insertion point after the word Circle at the end of the second line in the main_text div, and press Enter (Windows) or Return (Mac OS X) to create a new paragraph.
  6. Press the down arrow once to place the Insertion point before the capital letter T in the word The, and press the Backspace key once to delete the line break. There should now be three separate paragraphs in the main_text div (see Figure 12).

The text has been split into three paragraphs.

Figure 12. The text has been split into three paragraphs.

  1. Make sure the Property inspector is open (Window > Properties) and that the HTML button on the left of the Property inspector is selected.
  2. In the main_text div, place the Insertion point in the OPERATIVE WORDS line (anywhere in the line will do), and note that the Format is set to Paragraph in the Property inspector. This is the format Dreamweaver automatically created when you pressed Enter/Return to separate the lines of text.
  3. Select Heading 2 from the Format pop-up menu of the Property inspector.Note that you do not need to select the entire line of text before applying a format. This is because Dreamweaver is formatting the text by changing the text’s entire tag (from a paragraph tag to an h2 tag).
  4. Place the insertion point in the second line, the Stumbling line.
  5. Select Heading 3 from the Format pop-up menu of the Property inspector.
  6. Click the Split view button so that you can see the new tags (see Figure 13).Note: If the style sheet is still visible when you open Split view, select Source Code in the Related Files toolbar just below the page’s tab.

The h2, h3, and paragraph tags in Code view.

Figure 13. The h2, h3, and paragraph tags in Code view.

These tags are important. You’ll use them in the CSS to define the rules that will format the text.

  1. Click the check_cs5.css button in the Related Files toolbar to display the contents of the style sheet.
  2. In the CSS file, place the Insertion point after the closing brace of the #main_text rule and press Enter/Return a bunch of times to create some space (see Figure 14).

Creating space in the CSS file.

Figure 14. Creating space in the CSS file.

  1. Move the Insertion point back up until it’s just below the closing brace of the #main_text rule (you can use the up arrow key on your keyboard, or the mouse), and type the following empty rules into the file:

#main_text h2 { } #main_text h3 { } #main_text p{ }

The selectors for these rules (that is, the names outside the braces that define the rules) are called descendant selectors because they target HTML elements that are descendants of another element (in other words, nested inside it). The first of these selectors targets <h2> tags inside the #main_text div. What this means is that any styles defined in this rule will have no effect on the <h2> tags in the columns at the bottom of the page.

The second rule affects <h3> tags only if they’re inside the #main_text div. And the last one formats paragraphs (<p> tags) only if they’re inside the #main_text div.

Note: When using the New CSS Rule dialog box to create descendant selectors, you need to set the Selector Type pop-up menu to Compound. This is Dreamweaver’s way of describing CSS selectors that are created using multiple elements.

  1. The CSS file should now look as shown in Figure 15.

The CSS file with the new empty rules.

Figure 15. The CSS file with the new empty rules.

  1. Now, add the following properties and values to the empty rules so that they look like this:

#main_text h2 { color: #00b4e1; } #main_text h3 { font-size:16px; } #main_text p { font-size: 14px; }

  1. Once you’ve added properties to all three rules, press F5 or click once in Design view to refresh the display.Look what happened to the text. The h2 heading has turned blue; the h3 heading has been resized, and now fits on one line; and the paragraph text has been reduced in size (see Figure 16).

The main_text div text after applying new rules.

Figure 16. The main_text div text after applying new rules.

Note: For many years, it was recommended not to use pixels for the font-size property because the world’s most popular browser at the time, Internet Explorer 6, made it difficult for people with poor eyesight to resize the text. However, Internet Explorer 7 introduced a zoom feature, and issue is becoming less of a problem as Internet Explorer 6 gradually dies away.

You’re not quite there yet. The three sections of text are still a bit too spread out, and the paragraph text is bumping right up against the walls of the main_text div. You need to add a few more properties and values to fix that.

  1. Add three more properties and values to the #main_text rule, so that it looks as follows:

#main_text { background-color: #FFF; width: 300px; line-height: 1.2; font-family: "Myriad Pro", Helvetica, Arial, sans-serif; padding: 12px;}

The line-height property will increase the vertical space between all lines in the main_text div. (Yes, you do actually want to increase the general line height in the div—you’ll see why in a moment.) The font-family property will change the font of all the text in the div, and the padding property will add a 12-pixel padding inside the div.

Note: When you have a single value for padding, it acts as a shorthand value for top, bottom, left, and right. It is the equivalent of saying:

padding-top: 12px; padding-bottom: 12px; padding-left: 12px; padding-right: 12px;

  1. Refresh Design view by clicking inside it or pressing F5 to see how the new properties have affected the text.Lastly, get rid of some of the vertical space between the blocks of text, and condense the div.
  2. Add a margin property to the #main_text h2 rule, the #main_text h3 rule, and the #main_text p rule, so that the rules look as follows:

#main_text h2 { color: #00b4e1; margin: 0 auto; } #main_text h3 { font-size:16px; margin: 0 auto; } #main_text p { font-size: 14px; margin: 0 auto; }

The syntax for the margin property above is another short-hand notation, much like the one for padding in the previous step. When you declare only two values for the margin property, the first value declares the top and bottom values, and the second value declares the left and right values. By declaring a top and bottom margin of 0 for all three of these rules, you are effectively saying that there should be no extra space (other than the 1.2 line height) between the h2, the h3, and the paragraph text. The auto value in this case simply specifies the default value for the right and left of the h2, h3, and paragraph elements.

Tip: For more information about any CSS property, check the O’Reilly reference guide included with Dreamweaver. To display the guide, select Help > Reference and select O’Reilly CSS Reference from the Book pop-up menu in the Reference panel.

  1. Refresh Design view to see how the margin properties have affected the text (see Figure 17).

The main_text div after you have added margin properties and applied the rules.

Figure 17. The main_text div after you have added margin properties and applied the rules.

The text is looking pretty good, but before you go ahead and position the div, let’s check to see what the text formatting looks like in Live view.

  1. Click the Live view button.Design view displays the page in Live view (see Figure 18).

The formatted main_text div as it appears in Live view.

Figure 18. The formatted main_text div as it appears in Live view.

Hmm . . . that’s not exactly what I wanted. Monitors might differ, but on my screen the OPERATIVE WORDS h2 text still seems a little too close to the h3 text in Live view. Let’s fix that by adjusting the margin of the h2 heading one last time.

  1. Leaving Live View active, go back to the CSS file, and change the #main_text h2 rule to this:

#main_text h2 { color: #00b4e1; margin-top: 0; margin-bottom: 10px; }

  1. Refresh Live View by clicking back inside or pressing F5, and note the change (see Figure 19).

The main_text div after adjusting the margin properties for the h2.

Figure 19. The main_text div after adjusting the margin properties for the h2.

That’s much better!

  1. Click the Live View button to exit Live View.
  2. Select File > Save All Related Files to save the CSS file.

Position the main_text div

Now that you have the main_text div looking exactly the way you want, the final task is to position it on the page. There are several ways of doing this.

The approach taken in the original version of this tutorial series was to add padding to the top and left of the main_image div. This achieved the desired result, but many readers found it difficult to follow, because of the way CSS treats width and height when padding is added to an element. The CSS box model adds padding outside the width and height, not inside. As a result, to move the main_text div to the bottom right of the main image, you needed to subtract from the width and height of the main_image div the same amount as you added in padding. In other words, to add 100 pixels of padding to the top of the div, you needed to subtract 100 pixels from its height, so that the total of padding plus height still came to the same amount. Moreover, positioning the main_text div like this was possible only because the main_image div was empty. If you wanted to put more than one block of text inside the main_image div, the calculations became even more complex.

The approach I have decided to adopt this time is to use absolute positioning. Before showing you how to do it, I must sound a word of warning. Many beginners fall into the trap of trying to lay out their entire design with absolute positioning (or AP Divs, as Dreamweaver calls them). The attraction of absolute positioning is that you can place an element precisely on a page, making web design feel almost like desktop publishing. However, the web is a fluid medium. People view pages on different size monitors, and at different resolutions. Absolutely positioned elements behave in a very different way from other elements. They stay where you put them, and don’t interact with the rest of the page. So, it the user resizes the browser, an absolutely positioned element might disappear off screen. The browser doesn’t generate a scrollbar when this happens, so vital information might become inaccessible.

However, if used carefully, absolute positioning can be very effective, particularly when you want to align an element with a background image. In this case, the plan is to position the bottom right corner of the main_text div slightly above and to the left of the white cross at the bottom of the main image (see Figure 1).

  1. Click the Design button to view index.html in Design view.
  2. (Optional) Press F4 to hide the panels. You need to get a good view of the page layout, particularly of the main image.
  3. Select View > Rulers > Show. This adds rulers measured in pixels at the top and left of the Document window.
  4. Click inside the top ruler and drag down. As you drag, you should see a thin, green, horizontal line move down the page, with a yellow tooltip indicating how many pixels it is from the top of the page (circled in Figure 20).

Dragging a horizontal guide from the ruler at the top of the page.

Figure 20. Dragging a horizontal guide from the ruler at the top of the page.

  1. Continue dragging until the green line is flush with the bottom of the main image (around 491 px).
  2. Drag another guide from the top ruler until it’s in line with the position above the white cross where you would like the bottom of the main_text div to be. The exact position isn’t important. Use your eye to judge what looks good.
  3. Make sure your cursor pointer is between the green guides you have just positioned on the page, and hold down the Ctrl key (Windows) or the Cmd key (Mac OS X). Dreamweaver displays the distance in pixels between the two guides (see Figure 21).

Measuring the distance between the guides.

Figure 21. Measuring the distance between the guides.

  1. Make a note of the value.
  2. Drag two guides from the left ruler, and position them in line with the right edge of the main image and where you would like the right edge of the main_text div to be.
  3. Position your cursor pointer between the vertical guides and hold down the Ctrl key (Windows) or the Cmd key (Mac OS X), and make a note of the distance.
  4. The white cross is equidistant from the bottom and right edges of the main image, so the horizontal and vertical distances should be the same. I find that 60 pixels is about right.If you have difficulty positioning the guides, double-click one of the guides to open the Move Guide dialog box, and set the position by typing a value in the Location text box. Use 431 px for the horizontal guide. The value for the vertical guide will depend on the size of the Document window. Double-click the guide on the right edge of the main image to find its position, subtract 60, and use that value for the main_text vertical guide.
  5. Open the CSS Styles panel by clicking its tab, or by selecting Window > CSS Styles.
  6. Make sure the All button is selected to view the panel in All mode.
  7. Double-click #main_text to reopen the CSS Rule Definition dialog box for the #main_text style rule.
  8. Select Positioning from the Category list on the left, and add the following settings:
    • Set the value of the Position pop-up menu to absolute.
    • Type 60 in the Right and Bottom text boxes, and make sure the pop-up menus alongside are set to px.
    • Click Apply.

Using absolute positioning for the main_text div.

Figure 22. Using absolute positioning for the main_text div.

  1. Don’t worry if the main_text div remains stubbornly at the top-left of the main image div. Click OK to close the CSS Rule Definition dialog box, and select File > Save All Related Files to save the style sheet. The main_text div should move into position with its right and bottom edges aligned precisely with the green guides.Note: If the main_text area still doesn’t move. Try closing index.html and reopening it.
  2. Click the Live View button to verify the text is in the correct position (see Figure 23).

Live View confirms that the text is correctly positioned.

Figure 23. Live View confirms that the text is correctly positioned.

  1. With Live View still active, select #main_image in the CSS Styles panel, and move your cursor pointer over the left side of the Properties pane until you see the Disable CSS Property symbol next to the position property (see Figure 24).

Temporarily disabling a property in the CSS Styles panel

Figure 24. Temporarily disabling a property in the CSS Styles panel

  1. Click once to disable the position property. A red symbol appears alongside the property to indicate that it has been disabled.Note: The ability to disable style rules temporarily is new to Dreamweaver CS5. If you are using an older version of Dreamweaver, you will need to open the style sheet and manually comment out the position: relative;declaration.Look what has happened to the main_text div. It has moved from its previous position(see Figure 25).

The position of the main_text div is no longer relative to the main_image div.

Figure 25. The position of the main_text div is no longer relative to the main_image div.

The actual position of the main_text div depends on the size of your Document window. Instead of being positioned relative to the bottom and right of the main_image div, it’s now 60 pixels from the bottom and right edge of the Document window.

  1. Click the Disable CSS Property icon alongside the position property to re-enable it. The main_text div jumps back into place.What’s important to understand here is that the main_text div is nested inside the main_image div. In CSS terms,#main_text is the child of #main_image , and #main_image is the parent of #main_text . By setting theposition property of the parent to relative , the child is absolutely positioned relative to its parent. When you disabled the position property in #main_image , the absolute position of #main_text was calculated relative to the bottom and right edges of the browser window (in this case, Live View).
  2. Select File > Save All Related Files to save the page and the style sheet.
  3. Open the BrowserLab panel by clicking its tab, or by selecting Window > BrowserLab, and click Preview. Verify that the page looks as expected in all major browsers. Even Internet Explorer 6 plays ball.
  4. Select View > Guides > Clear Guides to remove the green guide lines from Design view.

Used in moderation, absolute positioning can be very helpful in situations like this. By using the bottom and right offsets, the bottom-right corner of the main_text div will remain in the same position, but it will grow taller if you add more text. A common mistake with using absolute positioning is the failure to realize that web pages are designed to be flexible. If you use absolute positioning for text elements, adding extra text is likely to result in one element overlapping another. It’s also important to understand the principle of anchoring an absolutely positioned element inside its parent by setting the parent’s position property to relative .

You have one more task to accomplish before the page is complete. In Part 5: Adding the spry menu you’ll add a Spry Menu Bar widget to the top of the page so that users can navigate the website.

Adobe Dreamweaver CS5 – Part 3: Adding content to pages


Adobe Dreamweaver CS4 logo

Image via Wikipedia

Requirements

Welcome to the third part of this tutorial series on creating your first website. This tutorial shows you how to add content to web pages in Adobe Dreamweaver CS5/CS5.5. You can add many different kinds of content to web pages, including graphics, text, links, and Spry widgets—to name just a few. After you’ve added content to your pages, you can preview your work in Dreamweaver so that you can see what it will look like on the web.

Note: You won’t be adding a Spry widget to the page until Part 5 of this tutorial series, Adding the Spry menu.

Locate your files and review your task

In this tutorial, you’ll begin with the CSS layout (index.html) you created in Part 2, Creating the page layout. If you did not complete that tutorial, you must complete it before proceeding, or download first_website_pt2_completed.zip(475 KB) and begin with those. All the required assets for this tutorial are in the check_cs5 local site folder that you set up in Part 1. If you are using the completed files from Part 2, follow the instructions in Part 1 for setting up the Check Magazine site on your local computer.

Your task is to add assets to the home page for Check Magazine, a fictional publication. You’ll learn how to add images, text, and links. You’ll also learn how to format text using CSS. Figure 1 shows what the finished page will look like at the end of Part 3.

The page after you have entered content into it.

Figure 1. The page after you have entered content into it.

Insert images

After you create your page layout, you are ready to add assets to the page, starting with images. You can use several methods to add images to a web page in Dreamweaver. In this section, you’ll add three images to the Check Magazine page using various methods.

Insert an image by using the Insert menu

In Part 2, you used the Insert panel to insert an image. This time, you’ll use the Insert menu.

  1. In Dreamweaver, open the index.html file that you created in Part 2, Creating the page layout.
  2. Delete the placeholder text in the left_column div. Make sure the Insertion point remains inside the div (see Figure 2). (In other words, make sure you don’t click anywhere outside the div after you’ve deleted the placeholder text.)

The left_column div with the placeholder text deleted.

Figure 2. The left_column div with the placeholder text deleted.

  1. Press Enter (Windows) or Return (Mac OS X) once to create more space in the div.
  2. Press the up arrow on your keyboard to move the Insertion point back up to the top of the div, and click the Split button to see what has happened in the underlying code. Dreamweaver has inserted two paragraphs ( <p> tags), each with &nbsp; inside them (see Figure 3).

Dreamweaver has inserted two empty paragraphs in the div.

Figure 3. Dreamweaver has inserted two empty paragraphs in the div.

Note: The &nbsp; is the HTML entity (code that represents a special character) for a nonbreaking space. It’s there to make the paragraph easier to select in Design view. Dreamweaver normally deletes it automatically as soon as you start typing or insert anything into the paragraph.

  1. Select Insert > Image.
  2. In the Select Image Source dialog box, navigate to the site’s images folder, select the car.jpg file, and click OK (Windows) or Choose (Mac OS X).
  3. Dreamweaver displays the Image Tag Accessibility Attributes dialog box (unless you’ve changed the default preferences).Type Car in the Alternate Text text box and click OK.The image appears in Design view, and Dreamweaver inserts the necessary HTML in the underlying code, removing the nonbreaking space in the process (see Figure 4).

The inserted car image and the underlying code.

Figure 4. The inserted car image and the underlying code.

  1. Leave the image selected (in other words, don’t click anywhere else on the page), and look at the Property inspector at the bottom of the Dreamweaver application window. (If the Property inspector is hidden, you can display it by selecting Window > Properties).

The Property inspector displays all of the properties for whatever asset you have selected in the Document window. Since we have our new image selected, the Property inspector is displaying the properties for the car.jpg image. You can see that the Property inspector displays the width and height of the image, the file path to the image, and the alternate text that you specified before inserting the image (see Figure 5).

The Property inspector displaying image properties.

Figure 5. The Property inspector displaying image properties.

The Property inspector is one of the most powerful tools in Dreamweaver. You can use it to change properties for any selected asset on your page at any time.

Note also that the <img> tag is selected in the Tag selector (at the bottom of the Document window)—yet another way that Dreamweaver communicates the precise selection of page assets.

Now let’s add the remaining images.

Insert an image by dragging

To insert an image by dragging:

  1. Delete the placeholder text in the center_column div. Make sure the Insertion point remains inside the div.
  2. Press Enter (Windows) or Return (Mac OS X) once to create more space in the div.
  3. Press the up arrow on your keyboard to move the Insertion point back up to the top of the div.
  4. In the Files panel (Window > Files), locate the data_addict.jpg file (it’s inside the images folder) and drag it to the insertion point in the center_column div (see Figure 6).Important: Make sure you drag the data_addict.jpg to the Insertion point at the top of the center_column div. It’s easy to mistakenly drop the image in the lower half of the div when dragging.

Drag the data_addict.jpg file to the insertion point in the center_column div.

Figure 6. Drag the data_addict.jpg file to the insertion point in the center_column div.

  1. In the Image Tag Accessibility Attributes dialog box, type Data in the Alternate Text text box and click OK.The image appears on your page. You can see all of its properties in the Property inspector.
  2. Save the page. It’s important to save often!

Insert an image from the Assets panel

To insert an image from the Assets panel:

  1. Delete the placeholder text in the right_column div. Make sure the Insertion point remains inside the div.
  2. Press Enter (Windows) or Return (Mac OS X) once to create more space in the div tag.
  3. Press the up arrow on your keyboard to move the Insertion point back up to the top of the div.
  4. Click the Assets tab in the Files panel group, or select Window > Assets to make your site assets appear.The images category in the Assets panel is selected by default. If it isn’t selected, click the Images button to view your image assets (see Figure 7).

The Images category of the Assets panel.

Figure 7. The Images category of the Assets panel.

The Assets panel displays assets for the site associated with the active document in the Document window. In the screen shot, you can see that the Assets panel displays the selected image asset in the preview area.

  1. In the Assets panel, select the helmet.jpg file.
  2. Do one of the following to insert the helmet.jpg file in the page:
    • Drag the helmet.jpg file to the insertion point in the right_column div.
    • Click Insert at the bottom of the Assets panel.
  3. In the Image Tag Accessibility Attributes dialog box, type Helmet in the Alternate Text text box and click OK.
  4. Save the page, which should now look as shown in Figure 8.

The page after inserting images in the columns.

Figure 8. The page after inserting images in the columns.

For more information on working with the Assets panel, see Working with Assets in Dreamweaver Help.

Insert text

Now you’ll add text to the page. You can type text directly in the Document window or you can copy and paste text from other sources (such as Microsoft Word or plain text files). Later, you’ll use CSS to format the text.

  1. Return to the Files panel by clicking its tab.
  2. In the Files panel, locate the text.txt file (in the check_cs5 root folder) and double-click the file’s icon to open it in Dreamweaver.You’ll notice that this window is in Code view (see Figure 9) and cannot be switched to Design view because it’s not an HTML file.

The text file opens in Code view only.

Figure 9. The text file opens in Code view only.

  1. In the text.txt Document window, select the first block of text (beginning with “Inside Tesla Motors®” up to and including “read more…”).
  2. Copy the text by pressing Ctrl+C/Cmd+C, or by selecting Edit > Copy. Alternatively, you can right-click and select Copy from the context menu that appears.
  3. Leaving the text.txt file open, click the tab of the index.html document.
  4. Click inside the left_column div below the car image, placing the Insertion point in the same place where you created space earlier (see Figure 10).

The Insertion point placed below the car image in the left_column div.

Figure 10. The Insertion point placed below the car image in the left_column div.

  1. Paste the text by pressing Ctrl+V/Cmd+V, or by selecting Edit > Paste. Alternatively, right-click and choose Paste from the context menu that appears.

The text is displayed in the div (see Figure 11).

The Inside Tesla Motors® text pasted in the div.

Figure 11. The Inside Tesla Motors® text pasted in the div.

Don’t worry about the look of the text. You’ll format it with CSS so that it looks more like the text in our design comp.

  1. Return to the text.txt file by clicking its tab.
  2. In the text.txt Document window, select the second block of text (beginning with “Facts and Figures” up to and including “read more…”).
  3. Copy the text.
  4. Leaving the text.txt file open, click the tab of index.html.
  5. Click inside the center_column div below the data image, placing the Insertion point in the same place where you created space earlier.
  6. Paste the text.
  7. And one last time, return to the text.txt file by clicking its tab.
  8. In the text.txt Document window, select the third block of text (beginning with “Today’s Self Improvement” up to and including “read more…”).
  9. Copy the text.
  10. Close the text.txt file by clicking the X in the upper-right corner of its tab. (You won’t need the remaining text until later.)
  11. On the index.html page, click inside the right_column div below the helmet image, placing the Insertion point in the same place where you created space earlier.
  12. Paste the text.Your three columns are now filled with text (see Figure 12).

The text in all three columns.

Figure 12. The text in all three columns.

  1. Save the index.html page.

Now all you need to do is format the text so that it looks more like what the designer intended.

Format text with CSS

In Part 2, Creating the page layout, you learned how to insert div tags and then position those tags on the page to create the layout. You separated content (the HTML div tags) from presentation (the CSS that controls the layout) by creating new CSS rules, placing them in an external style sheet, and then applying them to the div tags on your page. In a nutshell, you learned that you can insert elements on a page and create styling rules in a linked CSS page, and that when you apply those styling rules to particular elements on a page, those elements are directly affected by the rules.

Well, the same holds for text on a page. CSS is used to format text as much as it is to position div tags. You type or paste your text on the page, create a CSS rule, and then apply the rule to the text, just as you would apply it to a div. In fact, all text is contained within some sort of tag—it might be a div, but it could also be a paragraph tag ( <p> ), a heading tag ( <h1> , <h2> , etc) or any other kind of tag. Normally what you do when you format text with CSS is apply the CSS rule to the particular tag that you want to format.

Before going on, I recommend that you read Understanding Cascading Style Sheets, a basic overview of how CSS works to format text. Having a little background information about the ins and outs of CSS will make the rest of this tutorial a lot easier to comprehend.

Now let’s format some text.

  1. Open the CSS Styles panel (Window > CSS) by clicking its tab.
  2. (Optional) If it’s not already closed, double-click the Insert panel to close it and create more room.
  3. In the CSS Styles panel, click the All button to make sure you are viewing All mode.Earlier, when you first used the CSS Styles panel to create a new rule, the panel displayed no rules because you hadn’t created any yet. Now that you have a bunch of rules applied to elements on the page, the CSS panel is displaying all of the pertinent rules (see Figure 13).

Layout rules in the CSS panel.

Figure 13. Layout rules in the CSS panel.

In addition to creating and attaching new rules, the CSS Styles panel lets you track the CSS rules and properties that affect the elements on the page. All mode lets you see all of the page’s rules at once, while Current mode lets you see the rules that apply to the current selection on the page. The CSS Styles panel also lets you modify CSS properties without opening an external style sheet.

There are a number of ways we could go about formatting your text. Beginners often create class rules and apply them to each paragraph, but that’s a very inefficient approach. It’s better to use CSS to apply an overall style first, and use classes and other CSS selectors only for those elements that you want to style differently.

For now, all you need is a nice font format and size, and since you want your format to be uniform across all three columns, you can simply define the font format in a rule for the body tag ( <body> ). The body tag is the topmost tag of the HTML page, which means that all other tags on the page (including all of our div tags) inherit the properties defined for the body tag. By defining your text properties in the body tag, you will effectively be defining text properties for all text that appears on the page.

  1. In the lower right-hand corner of the CSS Styles panel, click the New CSS Rule button.
  2. In the New CSS Rule dialog box, do the following:
    • Select Tag from the Selector Type pop-up menu.
    • Type or select body in the Selector Name text box.

    Note the description in the text box below the selector name. Dreamweaver is telling you that the rule you’re creating will apply to all <body> elements. That’s exactly what you want.

  3. Make sure check_cs5.css is selected from the Rule Definition pop-up menu.
  4. Click OK.The CSS rule definition dialog box appears, indicating that you are defining properties for the new body tag rule.
  5. Select the Type category in the Category column. (It should be selected by default.)
  6. In the Type category, do the following:
    • From the Font-family pop-up menu, select Trebuchet MS, Arial, Helvetica, sans-serif
    • Click the Color box and use the eyedropper tool to select black (#000).
    • Click Apply.

    As soon as you click Apply, all the text in Design view should be formatted with the new style (see Figure 14).

You can check the effect of your styles by clicking the Apply button.

Figure 14. You can check the effect of your styles by clicking the Apply button.

Tip: If you want to experiment with different styles, you can change the values in the CSS Rule Definition dialog box, and click Apply to see the effect immediately reflected in Design view.

  1. While you’ve got the CSS Rule Definition dialog open, you should set a background color for the <body> tag. Although current browsers set the background color to white, it’s generally recommended to set the color explicitly in your own style rules—and, of course, you can choose any color you like.Select Background from the Category list on the left.
  2. Click the Background-color color box, and select white (#FFF).
  3. Click OK to close the CSS Rule Definition dialog box.You’ll notice two things. One is that Dreamweaver has added the new body tag rule to the CSS Styles panel (see Figure 15).

The new body rule in the CSS Styles panel.

Figure 15. The new body rule in the CSS Styles panel.

The other thing you might notice is the asterisk (*) that appeared next to the check_cs5.css file name in the upper left-hand corner of your document (see Figure 16).

The asterisk in the Related Files toolbar reminds you to save the changes to the style sheet.

Figure 16. The asterisk in the Related Files toolbar reminds you to save the changes to the style sheet.

What Dreamweaver is showing you here is that you have an unsaved related file.

  1. Select File > Save All Related Files to save the changes you made to the style sheet.

Format headings and create links

Now you just need to do a couple more things to finish formatting the text in your columns.

Format headings

To format headings:

  1. In the left_column div, place the Insertion point after the ® symbol at the end of the first line, and press Enter (Windows) or Return (Mac OS X).Note that the Insertion point is now on a line above the following text. Open Split view to understand what has happened. There’s a line break ( <br /> ) tag immediately after the opening <p> tag (see Figure 17).

The text you pasted into the columns contains &lt;br /&gt; tags.

Figure 17. The text you pasted into the columns contains <br /> tags.

When you pasted the text from text.txt, the newline characters were converted to <br /> tags. This gives the impression of paragraphs, but causes problems for formatting the text correctly. Pressing Enter/Return created a closing </p> tag at the end of the first line, and an opening <p> tag at the beginning of the next line, but the <br />tag wasn’t removed, leaving too big a space between the paragraphs.

  1. Make sure the Insertion point is still in the same place, and press your down arrow once to move the Insertion point before the word The.
  2. Press Backspace to delete the unnecessary line break (see Figure 18).

The line break has gone, leaving two paragraphs.

Figure 18. The line break has gone, leaving two paragraphs.

This is a very important step. The main paragraph text must be completely separated from the heading before we apply a format to the heading.

  1. Click anywhere in the heading text. For example, click in the word Tesla. You do not need to select any text—you only need to make sure that the Insertion point is somewhere in the heading text.
  2. In the Property inspector (Window > Properties), make sure the HTML button on the left is selected.
  3. Select Heading 2 from the Format pop-up menu (see Figure 19).

Select Heading 2 from the Format pop-up menu in the HTML Property inspector.

Figure 19. Select Heading 2 from the Format pop-up menu in the HTML Property inspector.

The Inside Tesla Motors® heading changes to a Heading 2. The size and weight of the text you see here is the default size and weight for a Heading 2. In other words, you did not really need to apply any CSS to achieve this effect (though you could have!)

Now you’ll do the same thing with the remaining headings.

  1. In the center_column div, place the Insertion point after the word Figures at the end of the first line of text and press Enter (Windows) or Return (Mac).
  2. Press the down arrow once, to move the Insertion point before the word How at the beginning of the next line, and press Backspace to remove the line break.
  3. Click anywhere in the heading text. For example, click in the word Figures.
  4. In the Property inspector, select Heading 2 from the Format pop-up menu.The Facts and Figures heading changes to a Heading 2.
  5. Lastly, in the right_column div, place the Insertion point after the word Improvement at the end of the first line of text and press Enter (Windows) or Return (Mac OS X).
  6. Press the down arrow once to move the Insertion before the word Whether at the beginning of the next line, and press Backspace to remove the line break.
  7. Click anywhere in the heading text. For example, click in the word Improvement.
  8. In the Property inspector, select Heading 2 from the Format pop-up menu.The Today’s Self Improvement heading changes to a Heading 2.
  9. Save the page.

Create links

A link is a reference, inserted in a web page, that points to another document. You can turn almost any kind of asset into a link, but the most common kind of link is a text link. In this section, you’ll turn the “read more…” text in each of our three columns into links.

The check_cs5 site root folder contains a finished HTML page that you can link to (a news page for the magazine). You’ll use this page for all of the links in the columns, even though you would have distinct pages for each of these links if you were building a real site.

Note: The news.html page is a dummy page made up of images, and is not intended for practical use. A follow-up tutorial will later show you how to create a functioning version of the page using a database and PHP server-side technology.

  1. In the left_column div, select the “read more…” text at the end of the paragraph, including the periods (see Figure 20).Tip: Because there’s no gap between the text and the left side of the div, you might find it difficult to select the text from left to right. Click and drag from the right—it’s much easier.

Selecting text in the left_column div.

Figure 20. Selecting text in the left_column div.

  1. In the HTML Property inspector, click the folder icon next to the Link text box (see Figure 21).

Clicking the Folder icon in the Property inspector.

Figure 21. Clicking the Folder icon in the Property inspector.

  1. In the Select File dialog box, select the news.html file (which is in the same folder as index.html) and click OK (Windows) or Choose (Mac OS X).
  2. Click next to the “read more…” text to deselect the link. You’ll see that the text has transformed into a link, underlined and blue.
  3. Repeat the previous steps and link the “read more…” text in the remaining two columns to the news.html page. When you’re finished, your page should look as shown in Figure 22.

The three columns with linked text.

Figure 22. The three columns with linked text.

  1. Save the page.

You just created three links to a page that’s internal to our site. But you can also use the Link text box in the Property inspector to create links to external websites. To do so, simply select the text or element you want to link, and then type the website’s full URL in the Link text box of the Property inspector. For example, if you wanted to link the third “read more…” text in our example to adobe.com, you would select the text, type in the Link text box, and press Enter/Return.

Note: When linking to an external site, you must include the http:// at the beginning of the URL. If you omit it, the browser treats it as an internal link.

Preview the page

Design view gives you a reasonably good idea of what your page will look like on the web, but you must preview the page in Dreamweaver or in a browser to see the definitive end result. With Dreamweaver CS5, you can preview your page directly in the Document window using Live View. You can also compare how your site looks in leading browsers by launching BrowserLab.

Preview your page in Live View

To preview the page, ensure that the index.html page is open in the Document window, and click the Live View button (see Figure 23).

Click Live View to preview the page inside Dreamweaver.

Figure 23. Click Live View to preview the page inside Dreamweaver.

Dreamweaver displays a preview of your page, just as it would appear in a browser. The page does not look all that different, as Dreamweaver does a pretty good job of displaying pages in Design view as they would look in a browser; but you’ll notice that small changes occur when you enter Live view—the outlines for all of the div tags disappear, for example.

Dreamweaver Live View uses WebKit as its rendering engine—the same engine that powers the Apple Safari browser, and a host of other applications such as Google Chrome and Adobe AIR.

Check links in Live View

In Dreamweaver CS5, Live View works just like a real browser, allowing you to follow links. Hold down the Ctrl key (Windows) or Cmd key (Mac OS X) when you click a link, and Dreamweaver takes you to the target page within the Document window—even if the link points to an external page on a different site (assuming you’re connected to the internet at the time).

  1. Click the Live View button to view index.html as it looks in a standards-compliant browser.
  2. Hold down Ctrl/Cmd and click one of the “read more” links.The news.html page appears in the Document window (see Figure 24).

You can follow links to other pages in Live View in Dreamweaver CS5.

Figure 24. You can follow links to other pages in Live View in Dreamweaver CS5.

Notice that there’s a Browser Navigation bar at the top of the Document window. It works in the same way as you would expect in a browser with Backward and Forward buttons. The Home button takes you back to the page you started from. You can even type a completely different URL in the Address text box, and Dreamweaver loads it into Live View (as long as the site is accessible).

If you don’t want to hold down Ctrl/Cmd each time you click a link, select Follow Links Continuously from the Live View Options menu (see Figure 25).

Select the option to follow links continuously.

Figure 25. Select the option to follow links continuously.

However, this works only during the current Live View session. If you turn off Live View, you need to select this option again the next time you launch Live View.

  1. Click the Home icon in the Browser Navigation bar to return to index.html, and click Live View to turn it off.

Preview your page in BrowserLab

BrowserLab is an online Adobe service integrated directly into Dreamweaver CS5 that lets you see what your pages look like in a wide range of popular browsers on both Windows and Mac OS X, saving you the need to install multiple browsers and operating systems locally.

To use BrowserLab, you need an Adobe ID. If you registered your Adobe ID during the installation of Dreamweaver CS5 (or Creative Suite CS5), you’re ready to go. Otherwise, select Help > Register, and follow the instructions onscreen to register for CS Live Services.

  1. With index.html open in the Document window, open the BrowserLab panel by clicking its tab, or by selecting Window > BrowserLab. Make sure you’re connected to the internet, and that the menu option alongside the Preview button in the BrowserLab panel is set to Local, and click Preview.Alternatively, press Ctrl+Shift+F12 (Windows) or Shift+Cmd+F12 (Mac OS X).
  2. Dreamweaver opens BrowserLab in your default browser, and prompts you to sign in with your Adobe ID. It then uploads your page and all related files and assets to the BrowserLab server.After a short while (the time depends on the speed of your Internet connection), BrowserLab displays your page as it looks in a range of different browsers and operating systems. You can create your own subsets of browsers and operating systems to test in, view different ones side by side, or superimpose them in “onion skin” mode.Figure 26 shows index.html as it currently looks in Safari 4.0 on Mac OS X and Internet Explorer 6 on Windows XP.

Comparing the Check Magazine page in different browsers in BrowserLab.

Figure 26. Comparing the Check Magazine page in different browsers in BrowserLab.

If you look closely at the image on the right of Figure 26, you can see that Internet Explorer 6 leaves no gap between the main image and the image in the columns (Internet Explorer 7 does the same).

Note: When checking the page in BrowserLab, you’ll notice that the main image is not rendered in Firefox 2.0 on either Windows or Mac, because it’s a background image. The market share of Firefox 2.0 is estimated at about 0.6 percent and falling, so it can be ignored, particularly since the image is purely decorative.

  1. Switch back to Dreamweaver, and add the following style rule at the bottom of the check_cs5.css style sheet:

p { margin-top: 1em; }

This adds a margin of one em to the top of each paragraph. An em is a measurement borrowed from typography. In CSS, one em is equivalent to the height of the current font. When typing the rule, make sure there is no gap between the number and the unit. Type 1em, not 1 em.

  1. Save check_cs5.css, and click the Preview button in the BrowserLab panel to refresh the version on BrowserLab.
  2. Select Internet Explorer 6 in BrowserLab. The images at the top of the columns are now correctly positioned (see Figure 27).

BrowserLab confirms that the paragraph style has fixed the problem.

Figure 27. BrowserLab confirms that the paragraph style has fixed the problem.

  1. Select Internet Explorer 7. The images are correctly positioned.
  2. Check the other browsers. The images are now in the same position in all of them. By default, most browsers add a top margin equal to the height of one line at the top of every paragraph. It’s just Internet Explorer 6 and 7 that weren’t playing ball. The style rule brought them back into line without affecting the look in other, more standards-compliant browsers.
  3. Close your browser window or tab to exit BrowserLab.

Preview your page in a browser

Using BrowserLab to compare how your pages look in different browsers on different operating systems is important before you publish them on the Internet. But sometimes, you just want to take a quick look in a browser or two on your local computer. That’s where Preview in Browser comes in useful.

To preview the current page in your default browser, just press the F12 key (Windows) or Option+F12 (Mac OS X). You can also edit Dreamweaver Preferences to register other browsers.

  1. Select Edit > Preferences (Windows) or Dreamweaver > Preferences (Mac OS X) to open the Preferences panel.
  2. Select Preview in Browser from the Category list on the left.
  3. Dreamweaver might already have detected other browsers on your computer. To add other browsers, click the plus button alongside Browsers to open the Add Browser dialog box.
  4. Type the name of the browser in the Name text box, and click the Browse button to navigate to the browser’s application file.
    • On Windows, this is normally the .exe file in the browser’s subfolder of C:\Program Files or C:\Program Files(x86).
    • On Mac OS X, select the browser’s name in the Applications folder.

    Tip: On Windows, Google Chrome is installed in a folder associated with your user account. To locate it, you need to enable the display of hidden files and folders. Right-click the application name in the Windows Start menu and select Properties to find the exact location.

  5. Select one of the browsers listed in the Browsers text area, and select the Secondary browser check box. To launch the current page in the Document window in your secondary browser, press Ctrl+F12 (Windows) or Shift+Opt+F12 (Mac OS X).
  6. To launch your page in a particular browser, select File > Preview in Browser, and choose the browser from the list. Alternatively, click the Preview/Debug in Browser button on the Document toolbar, and select a browser from the list (see Figure 28).

Select a browser from the list to preview your page locally.

Figure 28. Select a browser from the list to preview your page locally.

Note: For more information about working with Live View, see Previewing pages in Dreamweaver in Dreamweaver Help. For more information about previewing in browsers, see Previewing pages in browsers in Dreamweaver Help.

Your page is almost finished and ready for publication. In Part 4: Adding the main image text, you’ll add another div to the main image area and position it using CSS.

Adobe Dreamweaver CS5 – Creating your first website – Part 1: Set up your site and project files


Adobe Dreamweaver CS4 logo

Image via Wikipedia

 Requirements

Prerequisite knowledge

This tutorial requires no previous knowledge of Dreamweaver. However, familiarity with web design concepts such as HTML and CSS will be helpful. The tutorials in this series are designed to be completed in order.

User level

Beginning

Required products

Sample files

Note: This tutorial series was originally written for Dreamweaver CS4 by Jon Michael Varese. It has been updated for Dreamweaver CS5 by David Powers. The content is still valid for Dreamweaver CS5.5.

This tutorial introduces you to the concept of an Adobe Dreamweaver CS5 site and shows you how to set up the project files for the Check Magazine sample website. In Dreamweaver, a site generally consists of two parts: a collection of files on a local computer (the local site) and a location on a remote web server to which you upload files when you’re ready to make them publicly available (the remote site). You use the Dreamweaver Files panel to manage the files for your site.

The most common approach to creating a website with Dreamweaver is to create and edit pages on your local drive, and then upload copies of those pages to a remote web server for viewing on the web. In this tutorial, you’ll learn how to set up only the local site so you can begin building web pages right away. Later, after you’ve completed the website, you’ll learn how to create a remote site so that you can upload your files to a web server.

A follow-up tutorial series will show you how to adapt the website to use a server-side technology to create a simple content management system for a news page that draws its content dynamically from a database.

In this first part of the series, you will complete the following tasks:

  • Learn about Dreamweaver sites
  • Set up your project files
  • Define a local folder

Learn about Dreamweaver sites

In Dreamweaver, a site organizes on your local computer all the documents associated with your website and lets you track and maintain links, manage files, share files, and transfer your site files to a web server. Think of your Dreamweaver site as the “bucket” that contains all of the files and assets for your website.

A typical Dreamweaver site has at least two parts:

  • Local folder: This is your working directory. Dreamweaver refers to this folder as your local site. The local folder is usually a folder on your hard drive.
  • Remote folder: This is where you store your files on the computer that’s running your web server. The computer running the web server is often but not always the computer that makes your site publicly available on the web.

In some circumstances, you might have more than one remote folder. For example, if you work in a team environment, all members of the team might upload their files to a common testing server before they are deployed on the live website. Also, it’s normal to set up a testing server when developing websites that use a server-side technology, such as Adobe ColdFusion or PHP. The site setup process in Dreamweaver CS5 has been changed to enable you to define multiple remote and testing servers.

Another reason for the changes is to simplify the process of defining a site in Dreamweaver CS5. All you need to do to start working is to give your site a name, and tell Dreamweaver where you want to store the files on your local computer. Dreamweaver CS5 automatically prompts you for further information about the site setup only when it’s needed.

For more information about Dreamweaver sites in general, see Setting up a Dreamweaver site in Dreamweaver Help.

Set up your project files

When you create a local site, you can place any existing assets images or other pieces of content in the local site’s root folder the main folder for the site . That way when you add content to your pages, the assets are there and ready for you to use.

The sample files included in the download ZIP file contain assets for the sample website you’ll build in this tutorial series. The first step is to copy the sample files to an appropriate folder on your hard drive:

  1. Decide where you want to store your website files on your hard drive. The folder can be anywhere on your computer, but the less buried it is the easier it is to find later. For example:
    • Windows C:\Sites
    • Mac OS X Your home folder already includes a folder called Sites.
  2. Download and unzip the first_website_pt1.zip sample files from the link at the top of this page if you haven’t done so already.
  3. Copy the check_cs5 folder into the Sites folder.

The check_cs5 folder is the folder you will use as the root folder main folder for your Dreamweaver site.

Note: The local root folder of your Dreamweaver site is normally the main or top-level folder for your website. It usually corresponds to a folder called public_htmlwww, or wwwroot on your remote server. For example, if you have a website at http://www.example.com, and have a file called news.html in the root folder, its URL ishttp://www.example.com/news.html. The normal practice is to give your local root folder the same name as the website without the top-level domain such as .com or .org . For example, I store the files for my website athttp://foundationphp.com in a folder called foundationphp on my local hard drive.

Define a local site folder

You must define a Dreamweaver local site folder for each new website you create. Dreamweaver needs to know where your site files are to create all the internal links correctly, and to update them when you move files to a different location within your site.

Next, set up the site for this tutorial series and define as your local site folder the check_cs5 folder you copied into your Sites folder:

  1. Start Dreamweaver and select Site > New Site. The Site Setup dialog box appears.
  2. In the Site Name text box, enter Check Magazine as the name of the site. The name is used internally by Dreamweaver to identify the site. It doesn’t matter if it contains spaces.
  3. Click the folder icon next to the Local Site Folder text box to browse to and select the check_cs5 folder.
    1. The Site Setup dialog box should now look like Figure 1.

    Defining the local site folder for the Check Magazine site.

    Figure 1. Defining the local site folder for the Check Magazine site.

    Note: The file paths might differ, depending on where you created the Sites folder on your hard drive.

    1. Click Save. That’s it!

    The Files panel in Dreamweaver now shows the new local root folder for your current site (see Figure 2). The file list in the Files panel acts as a file manager, allowing you to copy, paste, delete, move, and open files just as you would on a desktop.

    List of files in the Files panel

    Figure 2. List of files in the Files panel

    For more information about how the Files panel works, see Work with files in the Files panel in Dreamweaver Help.

    You’ve now defined a local site folder for the Check Magazine site. This is where you keep the working copies of web pages on your local computer. Later, if you want to publish your pages and make them publicly available, you’ll need to define a remote folder—a place on a remote computer, running a web server that will hold published copies of your local files. You’ll learn how to do that in part 6 of this tutorial series.

    Where to go from here

    Now that you have finished defining your site, you can begin building your web pages by following Part 2 in this series, creating the page layout