17 May 2010
Beginning
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.
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.
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.
In Part 2, you used the Insert panel to insert an image. This time, you'll use the Insert menu.
<p> tags), each with inside them (see Figure 3).
Note: The 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.
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 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 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.
To insert an image by dragging:
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.
The image appears on your page. You can see all of its properties in the Property inspector.
To insert an image from the Assets panel:
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 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.
For more information on working with the Assets panel, see Working with Assets in Dreamweaver Help.
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.
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 is displayed in the div (see Figure 11).
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.
Your three columns are now filled with text (see Figure 12).
Now all you need to do is format the text so that it looks more like what the designer intended.
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.
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).
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.
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.
The CSS rule definition dialog box appears, indicating that you are defining properties for the new body tag rule.
As soon as you click Apply, all the text in Design view should be formatted with the new style (see Figure 14).
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.
<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.
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 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).
What Dreamweaver is showing you here is that you have an unsaved related file.
Now you just need to do a couple more things to finish formatting the text in your columns.
To format headings:
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).
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.
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.
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.
The Facts and Figures heading changes to a Heading 2.
The Today's Self Improvement heading changes to a Heading 2.
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.
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.
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.
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.
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).
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.
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).
The news.html page appears in the Document window (see Figure 24).
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).
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.
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.
Alternatively, press Ctrl+Shift+F12 (Windows) or Shift+Cmd+F12 (Mac OS X).
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.
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.
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.
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.
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.
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.
Tutorials and samples |
| 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 |