This content was uploaded by our users and we assume good faith they have the permission to share this book. If you own the copyright to this book and it is wrongfully on our website, we offer a simple DMCA procedure to remove your content from our site. Start by pressing the button below!
Nutshell Handbook, the Nutshell Handbook logo, the O’Reilly logo, and “The book that should have been in the box” are registered trademarks of O’Reilly Media, Inc. Dreamweaver CS4: The Missing Manual, The Missing Manual logo, Pogue Press, and the Pogue Press logo are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
ISBN: 978-0-596-52292-6 [M]
[4/09]
Table of Contents
The Missing Credits ................................................................................. xix Introduction................................................................................................. 1
Part One: Building a Web Page Chapter 1: Dreamweaver CS4 Guided Tour ........................................... 21 The Dreamweaver CS4 Interface ........................................................................................................... 21 The Document Window .................................................................................................................... 22 The Insert Panel ................................................................................................................................. 26 The Files Panel ................................................................................................................................... 28 The Property Inspector ..................................................................................................................... 30 The Application Bar ........................................................................................................................... 30 Organizing Your Workspace ............................................................................................................ 32 Setting Up a Site ....................................................................................................................................... 37 The Site Definition Wizard ................................................................................................................ 38 Defining a Site the Fast Way ............................................................................................................ 42 Creating a Web Page ............................................................................................................................... 44 The Dreamweaver Test Drive ................................................................................................................. 47 Phase 1: Getting Dreamweaver in Shape ....................................................................................... 48 Phase 2: Creating a Web Site ........................................................................................................... 52 Phase 3: Creating and Saving a Web Page .................................................................................... 53 Phase 4: Adding Images and Text ................................................................................................... 58 Phase 5: Preview Your Work ............................................................................................................ 65 Phase 6: Finishing the Page .............................................................................................................. 67
v
Chapter 2: Adding Text to Your Web Pages ........................................... 73 Adding Text in Dreamweaver ................................................................................................................. 73 Adding Special Characters ................................................................................................................ 74 Line Breaks ......................................................................................................................................... 75 Nonbreaking Spaces .......................................................................................................................... 77 Multiple Spaces .................................................................................................................................. 77 Adding a Date to Your Page ............................................................................................................. 78 Copying and Pasting Text ........................................................................................................................ 79 Simple Copy and Paste ..................................................................................................................... 79 Paste Special ....................................................................................................................................... 80 Pasting Text from Word: The Basic Method ................................................................................... 82 Pasting Text with Word Formatting ................................................................................................. 83 Pasting Excel Spreadsheet Information .......................................................................................... 84 Importing Word and Excel Documents (Windows) ...................................................................... 85 Selecting Text ............................................................................................................................................ 85 Spell Checking .......................................................................................................................................... 87 About Dictionaries ............................................................................................................................. 88 Performing the Check ........................................................................................................................ 88 Undo, Redo, and the History Panel ....................................................................................................... 90 Undo .................................................................................................................................................... 90 History Panel ...................................................................................................................................... 90
Chapter 3: Text Formatting ......................................................................93 Paragraph Formatting .............................................................................................................................. 95 Paragraphs .......................................................................................................................................... 95 Headlines ............................................................................................................................................ 97 Preformatted Text .............................................................................................................................. 97 Paragraph Alignment ........................................................................................................................ 98 Indented Paragraphs ......................................................................................................................... 99 Creating and Formatting Lists .............................................................................................................. 100 Bulleted and Numbered Lists ......................................................................................................... 100 Reformatting Bulleted and Numbered Lists ................................................................................. 102 Definition Lists .................................................................................................................................. 105 Removing and Deleting List Items ................................................................................................. 106 Text Styles ................................................................................................................................................ 107
Chapter 4: Introducing Cascading Style Sheets ................................... 111 Cascading Style Sheet Basics ................................................................................................................ 112 Why Use CSS? ................................................................................................................................... 112 Internal vs. External Style Sheets ................................................................................................... 113 Types of Styles .................................................................................................................................. 114 Creating Styles ........................................................................................................................................ 115 Phase 1: Set Up the CSS Type ........................................................................................................ 115 Phase 2: Defining the Style ............................................................................................................. 119 Creating a Style with the Property Inspector ............................................................................... 119
vi
Dreamweaver CS4: The Missing Manual
Using Styles ............................................................................................................................................. 122 Applying a Class Style ..................................................................................................................... 122 Removing a Class Style ................................................................................................................... 124 Applying IDs to a Tag ...................................................................................................................... 124 Linking to an External Style Sheet ................................................................................................. 125 Manipulating Styles ................................................................................................................................ 126 Editing Styles .................................................................................................................................... 126 Deleting a Style ................................................................................................................................ 127 Renaming a Class Style ................................................................................................................... 128 Duplicating a Style ........................................................................................................................... 130 Checking Browser Compatibility .......................................................................................................... 130 Text Formatting with CSS ...................................................................................................................... 133 Choosing a Font ............................................................................................................................... 134 Changing the Font Size ................................................................................................................... 137 Picking a Font Color ........................................................................................................................ 140 Adding Bold and Italics ................................................................................................................... 140 Aligning Text ..................................................................................................................................... 141 CSS Type Properties in the Rule Definition Window .................................................................. 141 Block Properties ............................................................................................................................... 143 List Properties ................................................................................................................................... 146 Cascading Style Sheets Tutorial ........................................................................................................... 148 Setting Up ......................................................................................................................................... 148 Creating an External Style Sheet .................................................................................................... 149 Editing a Style ................................................................................................................................... 151 Adding Another Style ...................................................................................................................... 153 Creating a Class Style ...................................................................................................................... 156 Attaching an External Style Sheet .................................................................................................. 158
Chapter 5: Links.......................................................................................161 Understanding Links .............................................................................................................................. 161 Absolute Links .................................................................................................................................. 162 Document-Relative Links ................................................................................................................ 162 Root-Relative Links .......................................................................................................................... 163 Link Types in Action ........................................................................................................................ 165 Executive Summary ......................................................................................................................... 167 Adding a Link .......................................................................................................................................... 167 Browsing for a File ........................................................................................................................... 167 Using the Point-to-File Tool ............................................................................................................ 170 Typing (or Pasting) the URL or Path ............................................................................................. 171 Using the Hyperlink Object ............................................................................................................ 172 Adding an Email Link ............................................................................................................................. 175 Linking Within a Web Page ................................................................................................................... 176 Method 1: Creating a Named Anchor .......................................................................................... 177 Method 2: Adding an ID ................................................................................................................. 178 Linking to an Anchor or ID ............................................................................................................. 179 Viewing and Hiding Anchors .......................................................................................................... 179
Table of Contents
vii
Modifying a Link ..................................................................................................................................... 180 Changing a Link’s Destination ........................................................................................................ 180 Removing a Link ............................................................................................................................... 180 Styling Links ............................................................................................................................................ 181 CSS and Links ................................................................................................................................... 182 Creating a Navigation Menu ................................................................................................................. 184 Adding a Menu ................................................................................................................................. 185 Adding, Editing, and Removing Links ............................................................................................ 186 Changing the Look of the Menu .................................................................................................... 188 Link Tutorial ............................................................................................................................................ 195 Linking to Other Pages and Web Sites .......................................................................................... 195 Formatting Links .............................................................................................................................. 197 Adding a Navigation Bar ................................................................................................................. 199 Styling the Menu Bar ....................................................................................................................... 203 Submenus and Rollover Buttons ................................................................................................... 208
Chapter 6: Images................................................................................... 213 Adding Images ........................................................................................................................................ 213 Adding an Image Placeholder ........................................................................................................ 216 Inserting an Image from Photoshop .................................................................................................... 217 Method 1: Using the Insert Image Object .................................................................................... 219 Method 2: Copying and Pasting from Photoshop ....................................................................... 224 Modifying an Image ............................................................................................................................... 224 Adding an ID to an Image ............................................................................................................... 225 Adding a Text Description to an Image ........................................................................................ 225 Changing an Image’s Size ............................................................................................................... 227 Some Properties to Avoid ............................................................................................................... 227 Controlling Images with CSS ................................................................................................................. 229 Wrapping Text Around an Image .................................................................................................. 229 Adding Borders ................................................................................................................................ 231 Background Images ......................................................................................................................... 233 Editing Graphics ...................................................................................................................................... 236 The Built-In Editing Tools ................................................................................................................ 236 Setting Up an External Editor ......................................................................................................... 239 Editing Smart Objects ...................................................................................................................... 241 Editing Images Pasted from Photoshop ........................................................................................ 244 Optimizing an Image ....................................................................................................................... 245 Image Maps ............................................................................................................................................. 245 Editing a Hotspot’s Properties ........................................................................................................ 248 Rollover Images ...................................................................................................................................... 248 Tutorial: Inserting and Formatting Graphics ...................................................................................... 251 Setting Up .......................................................................................................................................... 251 Adding an Image .............................................................................................................................. 251 Inserting a Photoshop File .............................................................................................................. 253 Inserting a Rollover Image .............................................................................................................. 257 Using Background Images .............................................................................................................. 259
viii
Dreamweaver CS4: The Missing Manual
Chapter 7: Tables ....................................................................................263 Table Basics ............................................................................................................................................. 264 Inserting a Table ..................................................................................................................................... 265 Selecting Parts of a Table ...................................................................................................................... 268 Selecting a Table .............................................................................................................................. 268 Selecting Rows or Columns ............................................................................................................ 268 Selecting Cells .................................................................................................................................. 269 Expanded Table Mode ........................................................................................................................... 269 Formatting Tables .................................................................................................................................. 270 Aligning Tables ................................................................................................................................. 270 Clearing Height and Width Values ................................................................................................ 271 Resizing a Table ............................................................................................................................... 272 Modifying Cell and Row Properties ..................................................................................................... 273 Alignment Properties ...................................................................................................................... 273 Table Header .................................................................................................................................... 274 A Property to Forget ........................................................................................................................ 274 Cell Decoration ................................................................................................................................ 275 Setting Cell Dimensions .................................................................................................................. 276 Tips for Surviving Table Making .................................................................................................... 276 Adding and Removing Cells .................................................................................................................. 278 Adding One Row or Column .......................................................................................................... 278 Adding Multiple Rows or Columns ............................................................................................... 279 Deleting Rows and Columns .......................................................................................................... 280 Merging and Splitting Cells ................................................................................................................... 280 Tabular Data ........................................................................................................................................... 282 Importing Data into a Table ........................................................................................................... 282 Sorting Data in a Table ................................................................................................................... 284 Exporting Table Data ....................................................................................................................... 286 Tables Tutorial ........................................................................................................................................ 286 Adding a Table and Data ................................................................................................................ 287 Modifying the Table ........................................................................................................................ 289 Formatting the Table ....................................................................................................................... 290 Final Improvements ........................................................................................................................ 294
Part Two: Building a Better Web Page Chapter 8: Advanced CSS.......................................................................299 Compound Selectors ............................................................................................................................. 299 Descendent Selectors ...................................................................................................................... 301 Styling Groups of Tags .................................................................................................................... 304 Fast Style Editing with the Properties Pane ........................................................................................ 305 Moving and Managing Styles ............................................................................................................... 308 More About CSS ..................................................................................................................................... 311 Inheritance ........................................................................................................................................ 312 The Cascade ..................................................................................................................................... 314 The Other Side of the CSS Styles Panel ........................................................................................ 315 Table of Contents
ix
Using the Code Navigator ..................................................................................................................... 320 Styling for Print ....................................................................................................................................... 322 Previewing Media Styles in Dreamweaver ................................................................................... 324 Tips for Printer Style Sheets ........................................................................................................... 325
Chapter 9: Page Layout ..........................................................................329 Types of Web Page Layouts .................................................................................................................. 331 Float Layout Basics ................................................................................................................................. 332 The Mighty
Tag ...................................................................................................................... 333 The Insert Div Tag Tool ................................................................................................................... 335 A Simple Example ............................................................................................................................ 337 Understanding the Box Model .............................................................................................................. 341 Dreamweaver’s CSS Layouts ................................................................................................................ 345 The Structure of Dreamweaver’s CSS Layouts ............................................................................ 350 Modifying Dreamweaver’s CSS Layouts ............................................................................................. 352 Making General Changes ................................................................................................................ 352 Modifying Fixed Layouts ................................................................................................................. 355 Modifying Liquid Layouts ............................................................................................................... 357 Modifying Elastic Layouts ............................................................................................................... 357 Absolute Positioning .............................................................................................................................. 358 The CSS Positioning Properties ...................................................................................................... 358 Adding an AP Div to Your Page ............................................................................................................ 366 Drawing AP Divs ..................................................................................................................................... 369 The AP Elements Panel .......................................................................................................................... 370 Modifying AP Element Properties ........................................................................................................ 371 Resizing Absolutely Positioned Elements ..................................................................................... 372 Moving AP Elements ........................................................................................................................ 372 Aligning AP Elements ....................................................................................................................... 373 Background Image and Color ........................................................................................................ 374 Nesting AP Divs ....................................................................................................................................... 374 CSS Layout Tutorial ................................................................................................................................ 375 Adding Content ................................................................................................................................ 379 Fine-Tuning the Layout ................................................................................................................... 380 Adding Styles and Navigation ........................................................................................................ 383 Fiddling with the Footer .................................................................................................................. 386
Chapter 10: Under the Hood: HTML...................................................... 391 Roundtrip HTML ..................................................................................................................................... 391 Auto-Fixing Your Code .................................................................................................................... 392 Web Application Server Pages ....................................................................................................... 393 Special Characters and Encoding .................................................................................................. 394 Code View ............................................................................................................................................... 395 Coding Toolbar ................................................................................................................................. 400 Code Hints ........................................................................................................................................ 402 Code Collapse .................................................................................................................................. 404 Setting Code Formatting ................................................................................................................. 406 Related Files ...................................................................................................................................... 410 x
Dreamweaver CS4: The Missing Manual
Live Code ................................................................................................................................................. 412 Quick Tag Editor ..................................................................................................................................... 413 Using the Quick Tag Editor ............................................................................................................. 414 Tag Inspector .......................................................................................................................................... 415 Comparing Versions of a Web Page .................................................................................................... 416 Using WinMerge to Compare Files ............................................................................................... 419 Using Text Wrangler to Compare Files ......................................................................................... 421 Reference Panel ...................................................................................................................................... 422 Inserting JavaScript ................................................................................................................................ 424
Part Three: Bringing Your Pages to Life Chapter 11: Forms...................................................................................429 Form Basics ............................................................................................................................................. 429 The Code Backstage ........................................................................................................................ 430 Creating a Form ..................................................................................................................................... 431 Adding Form Elements .......................................................................................................................... 435 What All Form Elements Have in Common ................................................................................. 435 Text Fields ......................................................................................................................................... 439 Checkboxes and Checkbox Groups ............................................................................................... 442 Radio Buttons and Radio Groups .................................................................................................. 445 Pull-Down Menus and Lists ............................................................................................................ 446 File Field ............................................................................................................................................ 449 Hidden Field ..................................................................................................................................... 450 Buttons .............................................................................................................................................. 451