Foundations of Microsoft Expression Web: The Basics and Beyond [1 ed.] 1590598059, 9781590598054

Microsoft Expression Suite promises new levels of power in creating rich dynamic user experiences on the web; Expression

289 33 8MB

English Pages 391 Year 2007

Report DMCA / Copyright

DOWNLOAD PDF FILE

Recommend Papers

Foundations of Microsoft Expression Web: The Basics and Beyond  [1 ed.]
 1590598059, 9781590598054

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

THE EXPERT’S VOICE ® IN WEB DEVELOPMENT

Foundations of Microsoft

Expression Web The Basics and Beyond Create standards-compliant CSS and HTML web sites with Microsoft Expression Web

Cheryl D. Wise

Foundations of Microsoft Expression Web The Basics and Beyond

Cheryl D. Wise

Foundations of Microsoft Expression Web: The Basics and Beyond Copyright © 2007 by Cheryl D. Wise All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-59059-805-4 ISBN-10 (pbk): 1-59059-805-9 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editors: Chris Mills, Matthew Moodie Technical Reviewer: Kathleen Anderson Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick, Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Jeff Pepper, Paul Sarknas, Dominic Shakeshaft, Jim Sumser, Matt Wade Project Manager: Beth Christmas Copy Edit Manager: Nicole Flores Copy Editors: Heather Lang, Kim Wimpsett Assistant Production Director: Kari Brooks-Copony Production Editor: Katie Stence Compositor: Molly Sharp Proofreaders: Lori Bring, Linda Seifert Indexer: Toma Mulligan Artist: April Milne Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com in the Source Code/Download section. You will need to answer questions pertaining to this book in order to successfully download the code.

This book is dedicated to my husband Steve and our two children, who were supportive even when writing this book interfered with our family life.

Contents at a Glance About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii About the Technical Reviewer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

■CHAPTER 1 ■CHAPTER 2 ■CHAPTER 3 ■CHAPTER 4 ■CHAPTER 5 ■CHAPTER 6 ■CHAPTER 7 ■CHAPTER 8 ■CHAPTER 9 ■CHAPTER 10 ■CHAPTER 11 ■CHAPTER 12 ■CHAPTER 13 ■APPENDIX

Before You Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Taking Your First Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Starting Off Right: Configuring Expression Web . . . . . . . . . . . . . . . . . 47 Using Semantic, Structured HTML to Create Web Pages . . . . . . . . . 83 Essential CSS: What You Need to Know . . . . . . . . . . . . . . . . . . . . . . . . 107 Using Expression Web to Create Basic CSS . . . . . . . . . . . . . . . . . . . . 147 CSS Positioning Using Expression Web Style Tools . . . . . . . . . . . . . 171 Branding Your Website . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 Dynamic Web Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 Legal and Usability Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 Master Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 Beyond the Basics in CSS and Scripting . . . . . . . . . . . . . . . . . . . . . . . 313 Extending Expression Web with Add-Ons . . . . . . . . . . . . . . . . . . . . . . 347

■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355

v

Contents About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii About the Technical Reviewer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

■CHAPTER 1

Before You Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Why Are You Creating a Website? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Typical Website Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Personal Sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Business Sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Attracting the Site Visitors You Want. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Picture Your Target Visitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Content Equals Credibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Keep Your List Simple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Points to Ponder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Choosing a Domain Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Personal Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Business Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Web Hosting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Hosting Using a Subdomain Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Commercial Web Hosting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 A Word About Web Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 What to Look for in a Web Host . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Simple Rules for All Websites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Installing Expression Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Choosing Your Install Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Taking Your First Look at Expression Web . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

vii

viii

■CONTENTS

■CHAPTER 2

Taking Your First Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Creating a Local Website . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 File Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Edit Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 View Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Insert Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Format Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

■CHAPTER 3

Starting Off Right: Configuring Expression Web . . . . . . . . . . 47 Using the Tools Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 General Tools Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Reports Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Optimize HTML Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Program Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Preferences Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Using the Site Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Remote Web Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Hyperlinks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Recalculate Hyperlinks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Site Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

■CHAPTER 4

Using Semantic, Structured HTML to Create Web Pages . . . 83 Required Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Structuring Your Web Page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Other HTML Elements from the Drop-Down List . . . . . . . . . . . . . . . . 96 Hyperlinks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 The Importance of Hidden Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

■CONTENTS

■CHAPTER 5

Essential CSS: What You Need to Know

. . . . . . . . . . . . . . . . . . 107

What Is CSS? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Why Use Stylesheets? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Types of Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 C for Cascade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Class and ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 and . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Setting Properties and Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Page Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Margin and Padding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Background Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Hyperlinks and Pseudo-Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Applying a Declaration to a Group of Selectors . . . . . . . . . . . . . . . . 135 Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Box Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Changing the Document Flow with CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Floats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Position Absolute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 Position Relative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

■CHAPTER 6

Using Expression Web to Create Basic CSS . . . . . . . . . . . . . . 147 Creating New Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Using the Block Category . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Setting the Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Creating a Border . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 Creating a Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Creating Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

■CHAPTER 7

CSS Positioning Using Expression Web Style Tools . . . . . . 171 Creating the Initial Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 Working with the Positioning Category . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 Working with the Layout Category . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 Building a Page Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

ix

x

■CONTENTS

■CHAPTER 8

Branding Your Website

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

Choosing a Color Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 Complementary Color Schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Analogous Color Schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Monochromatic Color Schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Choosing Images for Your Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Photos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Stock Photos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Image Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Adding Images to Your Web Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 Establishing Your Look and Feel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 Maintaining Your Branding Throughout Your Site . . . . . . . . . . . . . . . 230 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

■CHAPTER 9

Dynamic Web Templates

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

DWT Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 What Does a DWT Do? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 Creating the DWT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 Adding Editable Regions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 Editable Regions in the Section . . . . . . . . . . . . . . . . . . . . . . 238 Attaching DWTs to Your Web Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 Attaching a DWT to an Existing Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 Preparing an Existing Page for a DWT . . . . . . . . . . . . . . . . . . . . . . . . 245 Applying a DWT to a Page with Content . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 Moving Content Between Editable Regions . . . . . . . . . . . . . . . . . . . . 249 After the Template Has Been Applied . . . . . . . . . . . . . . . . . . . . . . . . . 250 Editing a DWT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 Detaching a Page from a DWT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 Changing the Attached DWT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

■CHAPTER 10 Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 Required Elements for a Form. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 Processing Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 Setting Form Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 ASP Send with CDO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 PHP Send Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 ASP.NET 2.0 Form Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286

■CONTENTS

■CHAPTER 11 Legal and Usability Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 Legal Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 Copyright . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 Privacy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 Usability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 Usability Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Where Can You Find Testers? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Using Expression Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Hyperlink Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Site Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296

■CHAPTER 12 Master Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 Creating a Master Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 Nesting Master Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312

■CHAPTER 13 Beyond the Basics in CSS and Scripting . . . . . . . . . . . . . . . . . 313 Alternative Stylesheet Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 Applying Different Media Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 Print Stylesheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 Validating your Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 ASP.NET Form Validation Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 ASP.NET Validation Controls Tag Properties. . . . . . . . . . . . . . . . . . . . 321 HTML Forms Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 Password Protecting a Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 Creating a web.config File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344

■APPENDIX

Extending Expression Web with Add-Ons . . . . . . . . . . . . . . . . 347 Adding PayPal Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 Adding Form Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349 Keyboard Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350

■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355

xi

About the Author ■CHERYL D. WISE, founder and director of WiserWays, LLC, has been creating websites since 1994. A member of the Guild of Accessible Web Designers and a World Organization of Webmasters Certified Professional Web Developer, Cheryl first received the Most Valuable Professional (MVP) award from Microsoft for FrontPage in 2003 and received the award every year until 2007. In 2007, Cheryl’s MVP award competency from Microsoft was changed from FrontPage to Expression Web. She teaches others to create standards compliant–accessible websites at Start to Web (http://starttoweb.com) and has been doing other online training since 2004. She is also the author of Introduction to Web Design with FrontPage 2003 (WiserWays: Houston, 2005) and is the owner of one of the best Expression Web resource sites on the Web—http://by-expression.com. You can contact her there.

xiii

About the Technical Reviewer

■KATHLEEN ANDERSON is a Microsoft MVP for FrontPage. She was the first woman to be honored with the FrontPage MVP award and is very happy that she is no longer the only one. Kathleen has been using FrontPage for ten years and is known as the “FrontPage Database Wizard Queen” by her fellow FrontPage MVPs. She chairs the State of Connecticut’s Committee on Web Site Accessibility. She loves to teach people how to make accessible web sites with FrontPage and is looking forward to doing the same with Expression Web.

xv

Acknowledgments I

’d like to acknowledge Tina Clarke, a fellow Microsoft FrontPage MVP and prolific e-book writer who encouraged me to write this book and nagged me to complete it. Tina’s support and constructive criticism helped make this book possible. Thanks also go to Pat Geary, Echo Swinford, and Sue Forrester for their encouragement and feedback; and to my editors at Apress, who were patient when my workflow didn’t match their standard editorial process.

xvii

d8b3179c1f3a5539ae0a590d20d3a408

Introduction T

his book is about more than just Microsoft Expression Web. For most people, a web editor is a means to an end—that end being a website that establishes a web presence. My goal in writing this book is for you to be able to use Expression Web to do more than just establish a presence: my hope is that you will be able to use Expression Web to create a website that fulfills the site owner’s goals. The days of being able to create a website that only works in one dominant web browser or on Windows-based computers are gone. Today, a website must look good and function properly in a variety of web browsers running on Windows and Macs. In addition, many people are using other devices such as game consoles, PDAs, and cell phones to access the Internet. Your website must function in each of these. This is what the term “cross browser” means. Web standards are what make it possible for your cross-browser website to work on the wide variety of devices and browsers out there.

What Is Expression Web? Expression Web is a new web editor from Microsoft built with web standards and cross-browser output as its primary focuses. Unlike older web editors, Expression Web was not compelled to work around the limitations of earlier versions with proprietary browser output and bloated code. Instead, Microsoft has created a modern web editor that meets the needs of today’s Web. Web 2.0 sites are frequently updated and standards compliant, and employ user-friendly interfaces that provide a clear, well-organized, and visually appealing site. Expression Web was designed to create standards-complaint websites out of the box, while at the same time providing tools to help effectively manage the look and feel of your website. Cascading Style Sheets (CSS), Dynamic Web Templates (DWT), and ASP.NET Master Pages are the foundation for creating and managing your website in Expression Web. Expression Web assists you in creating standards-complaint sites by writing the code to the specification of your choice, but it will not rewrite your code if you choose to use browser-specific code.

Why This Book? Many people whether they are new to creating websites or started creating them in the 1990s lack a foundation in web standards and CSS. Since Expression Web is focused on web standards and creating cross-browser websites, you must understand the basics of structured HTML and CSS to use its full potential. The early chapters of this book aim to give you the foundation you need to understand and use the tools in Expression Web to create and apply CSS. Learning how to use a web editor without understanding how websites work will leave you with a less-than-satisfying website. In this book, I explain not just the how to use features in Expression Web but why you should or should not use some of those features. Along the way, topics such as accessibility and usability will be introduced and explored.

xix

xx

■INTRODUCTION

Once you have that foundation, the book moves on to more advanced topics of creating robust page layouts that work in a variety of web browsers, handling legacy browser issues, and creating contact forms By the time you reach the end of the book, validating your forms and sending the results by e-mail, creating print stylesheets, and password protecting a section of your site will all be within your capabilities.

What Is Not in This Book? This book is not a manual. To cover every possible thing you can do with Expression Web would require a much longer book than this one. When you find a feature in Expression Web in this book, it will be for a real-world purpose.

Who Is This Book For? This book is for the web designer, not for the web developer. While this book does contain sample form–to–e-mail scripts in three server-side languages and simple form field validation and password protection scripts, this book does not go in-depth on the ASP.NET controls in the Toolbox. Instead, this book focuses on the design and maintenance of websites. Microsoft Expression Web is a tool that will make some aspects of creating a website easier—it is not a substitute for understanding how websites work. With this book, you will learn both the tools and the fundamentals of creating websites.

How Is This Book Structured? The best way to learn to create a website using any program is to actually use it, which is why each chapter includes exercises designed to reinforce the topics it explains. I recommend working through each of these exercises for hands-on experience. Working examples of the completed exercises can be viewed at http://foundationsofexpressionweb.com, and the complete source code can also be obtained from http://www.apress.com/ in the Source Code/Download section. Sidebars will provide you with explanations of concepts and best practice tips for creating your website.

Where Can I Find More Information? Expression Web is a new program; as a result, features and bugs are still being discovered. If you have questions about something you find or don’t find in the program, there are a few places I recommend checking: my site http://by-expression.com and the Microsoft Public Newsgroup/Forum (news://msnews.microsoft.com/microsoft.public.expression.webdesigner in Outlook Express or Windows Mail). Since URLs may change, a list of links to other places on the Web with Expression Web resources will be maintained at http://foundationsofexpressionweb.com/links.

CHAPTER

1

Before You Begin A

s great as the temptation is to jump right in and start creating your website, you should do a few things first, in order to make sure the site you create is effective. Web standards are important, but planning is even more important to the success of your website. If you do not have a clear vision of your site goals or know which of the many goals you have are most important, how can you expect your visitors to understand and share in your vision and enthusiasm? In this chapter, we will determine your site needs and follow through with site planning, which will make creating and maintaining your site easier. You will also install Expression Web and become familiar with its interface.

Why Are You Creating a Website? Every website has a purpose. It must fulfill a need, whether that need is to sell a product, promote your business, provide support for a product, interact with or create a community of people with a shared interest or passion, or simply express yourself—to share your views, art, and so forth. While many people think of a website as a design or a set of features, that is approaching your site from the wrong direction. Start with what you want your site to achieve instead of with a set of features you think you want. You may have watched home-improvement shows like Mission: Organization or Clean Sweep. You look at the “before” picture and think, “How could that mess have happened?” It could easily happen to your website. In your excitement to get your website up, it’s tempting to just begin. Don’t do it—starting to create a site without proper preparation can prove to be a big mistake when your site grows out of control with no clear purpose. Take time to jot down your thoughts about each of the topics in this section.

■Note Start by setting out your vision: what do you or your clients want the site to accomplish?

In addition to determining the purpose of your site, you need to know who your website’s target audience is. A website for gamers will need a very different look and feel than a website

1

2

CHAPTER 1 ■ BEFORE YOU BEGIN

selling home childproofing devices and safety seats. Site content goes hand in glove with the purpose of your site and your target audience. Without content, you will not attract visitors or keep them on your site long enough to fulfill your site goals. Unlike in the movie Field of Dreams, just because you build it doesn’t mean “they will come.” Consider the quantity and type of content you have or can develop when planning your website. If this is a new website, a domain name and web hosting will need to be obtained (more on this later in the chapter). If the website already exists, you should evaluate your existing site to determine if it is achieving your site goals. We will begin with the typical reasons for creating a website.

Typical Website Objectives While there is frequently some overlap, websites are basically divided into two general categories: personal or business.

Personal Sites Personal sites are often made for one of the following uses: • For fun: To share your personal thoughts with the world at large, consider a blog instead of a traditional website. You can use Expression Web to personalize and make even a standard blog application reflect who you are. • For keeping in touch with family and friends: Examples are a site for planning family reunions or for sharing photos and video clips. • For sharing a hobby or interest with fellow enthusiasts: This may have elements of a community site or be more like a personal blog site. • As a neighborhood or group site: Creating this type of website is typically a volunteer position when you are part of an organization such as a garden club, scouts, neighborhood association, or other non-profit group.

Business Sites Most sites on the Web have at least some business component. The most common types of business sites follow: • An e-commerce site: To sell a product online, usually through the aid of a databasedriven shopping cart. An e-commerce site can also be a static site with payment buttons for PayPal, Google Checkout, or some other payment gateway. • An information site: To provide product or company information, including frequently asked questions, shipping terms, privacy policies, and other information that would be of interest to customers, with perhaps a secondary goal of selling products. You can save money on support costs when manuals, product specification, and other materials are available to your customers online.

CHAPTER 1 ■ BEFORE YOU BEGIN

• A brochure website: To follow up offline marketing such as television, radio, and telephone advertising where either cost or space does not allow all the information to be in the offline marketing. • Find new customers: To expand your customer base into new markets. This can be especially important when your products are specialized ones that attract a small number of enthusiasts. It’s common to have more than one objective on a business site. A short list follows: • Giving visitors a favorable impression of your company or organization • Developing a qualified prospect list • Selling products directly by taking credit card information over the Internet • Encouraging potential customers to phone or mail you to consummate a sale • Making product information and price lists available to distributors • Making product information and price lists available to customers • Strengthening brand identification • Creating a community of users Decide what your objectives need to be, and rank them in priority. Next, consider who your target visitor will be.

■Tip Be realistic about who will visit your site and what they will do there.

Attracting the Site Visitors You Want Before your site can achieve your goals, you must not only know what your site objectives are but also what visitors you need to attract to your site to accomplish those goals. A site with the objective of selling $900 latte machines will not succeed if it only attracts college students. No matter how much coffee the students might drink, few can afford to spend $900 for their coffee makers. Their parents are more likely to be in a position to afford the machines and would likely make purchases for themselves, not their offspring.

Picture Your Target Visitor Typically, you will have some idea of the people you want to visit your site even if it is, “I want people to come, spend lots of money, and make me wealthy enough to retire in two years.” If

3

4

CHAPTER 1 ■ BEFORE YOU BEGIN

your target is too broad, you will need to narrow it. Look at the following examples to see how you can narrow down the target for a site selling children’s clothes: • Focus on the current customers, or, if the business is new, on those who are likely to become customers. Then, combine the characteristics of those customers into two or three different “people” to represent your target market. • Be realistic about your target customers. For example, our children’s clothing site might include the following target customers: • Stay-at-home moms with too many children to take shopping simultaneously • Working mothers with no time to shop • Grandparents who want well-dressed grandchildren to show off in pictures • Decide what elements the potential visitors have in common. See if your target market is too broad or too narrow.

Content Equals Credibility No matter how great your site looks or how well you know your target audience, a site without content will not be successful. There must be well written content for your website to rank well in search engines. Even if your visitors arrive at your site as a result of offline promotion, direct links, and personal referrals, there must be content that will keep them on your site once they have found it. The nature of your content as well as your site purpose and target audience will determine the feature set you need to have on your site.

■Tip Remember the KIS principle: Keep It Simple.

When you know what content you will have, you can start to organize your site to perform the functions that visitors expect and/or need to see. Structure your website to make it easy for your visitors to find what they need. Putting your site structure on paper will help you see your site’s organization. This site map does not need to be as complicated as the one shown in Figure 1-1. Instead, a site map can be something as simple as hand written notes on categories and connections between them, as Figure 1-2 shows.

CHAPTER 1 ■ BEFORE YOU BEGIN

Figure 1-1. Site diagram with anticipated navigation paths

Figure 1-2. A hand-drawn site plan

5

6

CHAPTER 1 ■ BEFORE YOU BEGIN

Keep Your List Simple Whether you choose to set down your ideas in a computer file or on a piece of paper, your first notes should be little more than what fits on the back of an envelope. Otherwise, you may not have clarified your thoughts sufficiently. Keeping your list simple will help you crystallize your goals and keep your focus on them.

Points to Ponder People use the Web primarily as a tool or utility with some purpose in mind. Except for a few special-purpose sites such as those for movies or games, most people don’t visit a website just for entertainment. Most site visitors have something in mind before they visit a website. This means that an attractive site is not enough. Your site must be usable and must draw your visitors with content that meets their needs while at the same time serving your site goals. If this site is an adjunct to an existing business, ask you customers what they would want to find on your site. As you plan your website, remember these fundamentals: • It’s not enough to know you need a website. • You must know the purpose your website is to serve. • You must know who will use your site—your target audience. • Realize that the Web is not print and it is not television. • The site visitor is the one who has ultimate control.

Choosing a Domain Name Every website on the Internet has a numerical address called an Internet Protocol (IP) address, which is four sets of up to three numbers with each set separated by a period. For example, Apress, the publisher of this book, has its website at 65.19.150.101. Most people have difficulty remembering strings of numbers and are better at remembering names. When you register a domain name, your visitors will be able to type in http://apress.com instead of the number of the Apress site. Your web host will then resolve your domain name to the numeric address of your hosting server. This allows more than one website to be hosted on the same server and IP address.

■Tip Easy to remember is better than short when it comes to domain names.

The number one limitation of choosing a domain name is whether it’s available. You can check domain name availability at any registrar’s website. Several registrars are listed on this book’s companion website at http://foundationsofexpressionweb.com. The second limitation is that a domain name can be no longer than 255 characters. While the maximum length of a URL is not known, Internet Explorer has a maximum of 2,083 characters, which is the least

CHAPTER 1 ■ BEFORE YOU BEGIN

number of characters of any major browser, making 2,083 characters the effective maximum length. Despite the availability of long domain names and paths for internal lengths, remember that your visitor will need to type in that address. Every domain ends with a top-level domain, or TLD. See Table 1-1 for a list of common TLDs. Table 1-1. TLDs

Types of TLDs available Original Unrestricted TLDs

com

net

org

country code *

Original Restricted TLDS

edu

gov

mil

int

Unrestricted TLDS added in 2001

biz

info

name

Restricted TLDs added in 2001

pro

aero

coop

museum

* Each country reserves the right to determine the conditions for using country-specific domain extensions; some act as international open domain names, such as .tv, but that is subject to contract between the country and its authorized registrars. A list of all the countries with approved country codes and their two-character extensions is available at http://www.iana.org/root-whois/index.html.

Domain names consist of a name and a top-level extension, which means that every domain out there is a second-level domain. Third-level domains, frequently called subdomains, are domains such as events.microsoft.com, my.yahoo.com, or groups.google.com. When you see a domain name that uses www.domain.tld, you are actually seeing a third-level domain name and not the root of the domain. With very few exceptions, such as www, you will not want to have a subdomain for your website unless you own the primary, second-level domain name.

■Note You can register a domain name before you obtain web hosting. My recommendation is to register your domain name separately from your website hosting. That way you can easily transfer your domain if your hosting needs change.

Personal Site For a personal site, use any name you want. Your name, a nickname, or even nonsense can be used as long as no one else has registered the name you want. Be creative, but think about how your site may grow or change in the future before you register that really cute name—you may outgrow it. For a personal site, you may use any unrestricted TLD name including: .com, .net, .org, .info, .name, or your country code.

■Note While the .name extension is an unrestricted domain, until recently you were only allowed to register a third-level or subdomain name, such as http://john.doe.name. Global Name Registry, the administrators for the .name TLD, have promoted third-level domains as “your email address for life.” It is not clear that you can host a website with a TLD of .name, so I would not recommend using a .name TLD for your website.

7

8

CHAPTER 1 ■ BEFORE YOU BEGIN

Business Site For a business site, you may use any one of the unrestricted TLDs except .name. If the site owner is an individual or professional organization meeting the requirements for legal, medical, and accounting professions, you may want to consider a .pro extension. The .pro extension was created as a TLD restricted to these professions.

■Note The .pro extension was created to provide a level of confidence that the person or entity is a licensed practitioner in that field. The majority of .pro domain names will be third-level or subdomains of law.pro, cpa.pro, and med.pro to reflect that the domain owner is a licensed professional in the category their domain was created in. As part of a .pro registration, the registrar, Registry Pro, verifies that the applicant is a licensed professional in the United States, Canada, Germany, or the United Kingdom. In addition, when the domain name is issued, a digital certificate will be issued for use either on the registrant’s website (via Secured Socket Layer encryption) or e-mail (via s/MIME) to provide for the confidential transfer of information. Only those companies or individuals who qualify in two or more categories will be able to obtain a second-level domain.

If your business can obtain its business name with a .com extension you should purchase that domain name as soon as possible, even if you are not ready to publish your site. Protecting your first choice is worth the small expense (under $10) to ensure that the name will be available when you are ready to launch your website. Check the availability of your preferred name before you go any further. If you do not currently have a domain name registrar, a partial list of registrars is available at http://foundationsofexpressionweb.com. If your company name or name of choice is not available for purchase as a .com, check to see who has the .com version before you purchase a domain name with a different TLD. If you use a domain name that ends in a TLD other than a .com extension, many visitors will visit the .com version without noticing your domain name does not end in .com. If your first choice name with a .com extension is taken, it might be better to choose a different name than to risk sending your traffic to a competitor. Another desirable option is to register both the .com and the country-specific domain extension, especially if you plan to do business in more than one country. Many businesses outside the United States use their country codes as an alternative to .com. Many large companies, such as Coca Cola, Nike, and Toshiba, register the country extension for the countries in which they do business and in which they plan to do business in the future.

Web Hosting You need to make your site available on the Internet for people to visit. That means you must have space on a web server connected to the Internet. This is called web hosting, and there are many options. In most cases, you will want your website to be hosted by a commercial web hosting company that specializes in running web and database services using your own domain name. For a personal website, registering and using your own domain name is not strictly necessary.

CHAPTER 1 ■ BEFORE YOU BEGIN

Hosting Using a Subdomain Name Several options don’t require registering a domain name, arranging for web hosting, or other additional expenses. The primary advantage to using one of these is the cost. Usually subdomains are either free or included with something you already pay for as part of an Internet service.

ISP Hosting Most people who use the Internet have a certain amount of web space available from their Internet Service Provider (ISP) providing their Internet connection, such as AOL, Road Runner, AT&T, Orange, or BT. Typically, the space is limited to around 5MB. This is more than adequate for many personal sites. ISP-provided hosting is usually very basic, since the primary business of an ISP is providing access to the Web, not providing full-featured, secure web hosting. Drawbacks to using ISP hosting frequently include the following: • You have no choice over your site’s URL, which usually looks something like http://www.earthlink.com/~user. • If you change ISPs, your site will no longer be available at the same URL. You will have to notify everyone of your new URL. • Search engines don’t index ISP-provided sites. • There’s no support for server-side scripting, such as ASP, PHP, or ASP.NET. • Transferring files from your computer to the web space usually is by File Transfer Protocol (FTP) but may require using a proprietary tool. While ISP-provided web hosting has drawbacks, it’s a good place to test practice pages.

■Note Many domain registrars offer domain forwarding, where people use your domain name and the domain registrar’s servers transfer all requests to your ISP-provided hosting. This can be a cost-effective solution to the first two drawbacks.

Free Hosts GeoCities, Yahoo!, and Tripod are examples of portals offering free web hosting in exchange for allowing banners or other advertising to be placed on your site. Some disadvantages follow: • Third-party advertising may include code that interferes with your web page functions, especially if you are using JavaScript for menus. • You have little or no ability to use server-side code on your website. • Usually, there’s no ability to process a form. • Frequently, these portals require the use of proprietary upload managers.

9

10

CHAPTER 1 ■ BEFORE YOU BEGIN

• Search engines rarely index free hosting service sites. • All free hosting options require you to maintain your own site backups. • Generally, there is little or no technical support. In cases where support is available, a fee often is charged, by the hour or on a per-incident basis.

Commercial Web Hosting Commercial web hosting gives you the most flexibility, though it costs money (but not much money for small websites). In the 1990s, a very tiny amount of web space would cost $30 or more per month; now, you can get generous hosting for under $10 a month, which makes commercial web hosting affordable even for personal websites.

■Note There is no viable alternative to commercial web hosting for a business site.

The cost can range from $1.99 per month to whatever you want to spend. Normally, you will both want and need to register a domain name. Many web hosts offer to register your domain and keep it current while you host with them. While this may be tempting, especially when the offer is for free registration, if you later decide to change hosting providers, doing so may be more difficult than if you keep the registration separate from the domain hosting. Some of the benefits of commercial web hosting follow: • A URL never changes as long as you keep your registration current and pay your hosting fees. Even if you change ISPs or domain hosts, your URL remains the same. • You own and control the domain name. • Search engines will find and index your website. • You can choose the options that suit your site needs including • Amount of space • Type of server • Server support for ASP, ASP.NET, PHP, and other server-side scripting languages • Security, whether it is private areas of your site or the ability to deliver Secure Socket Layer (SSL) encryption for e-commerce • High-speed redundant connections between your server/site and the Internet backbone. • Regular site backups to protect you from server failures. • Technical support if you need help with setting up your site.

CHAPTER 1 ■ BEFORE YOU BEGIN

• Permanent e-mail addresses that you control. Most hosts offer POP3 and SMTP mail services so you can use Outlook, Windows Mail or iMail with your domain name. Those that don’t offer e-mail forwarding to your ISP account.

■Note Even if your domain is not yet hosted, many registrars offer to forward e-mail to you.

A Word About Web Servers There are basically two types of web servers available for commercial web hosting: Linux based and Windows based. Expression Web will create sites that run on any server platform. However, if you plan on using the advanced features, such as data connections and master pages, a web server with ASP.NET 2.0 installed is your best choice, since in the first release version of Expression Web, the only server-side language that has IntelliSense support is ASP.NET 2.0.

ASP.NET FOR NON-MICROSOFT SYSTEMS Contrary to the beliefs of many, ASP.NET is not a proprietary technology owned by Microsoft but is an ECMA/ISO standard for both the Common Language Interface (CLI), and the C# language. See http://www.ecma-international.org/news/PressReleases/PR_TC39_CSharp_CLI.htm if you would like more information on the standard. At the time of this writing, the Linux and Macintosh versions of ASP.NET support ASP.NET 1/1.1 features and a limited set ASP.NET 2.0 classes on Mono 1.2. More ASP.NET 2.0 features are under active development. To find out the status of ASP.NET support, please visit the Mono Project website: http:// mono-project.com.

What to Look for in a Web Host A list of items you should take into account when deciding on a web host follows: • Bandwidth: Look for a host with fat pipes and redundant high-speed connections to the Internet. That way, if one connection goes down, your site will still be available using a backup connection. • Hosting space: How much space do you need? Most static sites need less than 5MB, but many web hosts count your server log files in the amount of space available in your plan. Log files will tell you about the browsers, operating system, and behavior of your visitors but can grow very large, especially if your site is popular.

11

12

CHAPTER 1 ■ BEFORE YOU BEGIN

• Reliability and support: Ask for recommendations from people you know who already have websites to see if they are happy with their web hosting. Check online forums and reviews. Most web hosting companies will offer a 30-day money-back guarantee; use that time to find out how their technical support works. Also find out what sort of server backups the host offers. • Server-side language and database support: Even if you do not think that you will use a database, if you are paying for hosting, make sure at least one database and one serverside language are supported. To use the database and server-side tools in Expression Web, look for a web server with ASP.NET 2.0 and Microsoft SQL Server or Microsoft Access support. While you will not be able to use IntelliSense, you can write code directly in Code view. You will also be able to designate a third-party editor for serverside scripts such as PHP for use with Expression Web.

■Note FrontPage Server Extensions are not required for Expression Web, but if your web host offers FrontPage Server Extensions, you may continue to use them to send form results by e-mail.

Simple Rules for All Websites Following these simple rules will make your site better: • Match your site to your goals. • Use the Web for what is it and what it does well. • Good site functionality beats the latest and greatest web technology or bells and whistles. • Start simply. • Stay focused. • It is easier to add content, features, and function than to remove them. • Most importantly, high-quality content is the single most vital key to a successful website. • Site goals must be • Relevant • Measurable • Realistic • Prioritized • Keep the site’s content current.

CHAPTER 1 ■ BEFORE YOU BEGIN

Installing Expression Web Now that you have a site plan in mind, it is time to get started. If you have not yet installed Expression Web, now is the time to do so. To install Expression Web, you must be using either Windows XP with Service Pack 2 or Vista. It does not matter which version you use, as long as your operating system is supported.

■Note To use Expression Web effectively, I recommend a minimum screen resolution of 1024×768.

After you insert the Expression Web CD in your drive and agree to the licensing agreement, you are presented with the choice to Install Now or Customize. The default install of Expression Web is a good choice for those who will be working on basic websites and those hosting on a web server that does not support ASP.NET 2.0.

Choosing Your Install Type By default, Expression Web will install to your C:/Program Files/Microsoft Expression folder and include some of the Office 2007 tools, such as the spell-checker and file converters. The most frequently used converters and tools will be installed, while other options, such as the ASP.NET 2.0 web server and script editor, will be set to install on first use. If you do not know if you will be using server-side scripting, use the default install.

A Default Install For a default install use the Install Now button and skip to the “Taking a First Look at Expression Web” section. If you have sufficient hard disk space, consider using a customized install so that you will have all the components available without the need to have the Expression Web disk available to install those components when you are ready to use them. Other reasons to use a customized install are to install Expression Web in a location other than the Microsoft default of C:\Program Files\Microsoft Expression or to install the classic ASP scripting tool.

■Note The number one reason for a custom install is if your website will be hosted on a web server with ASP.NET 2.0.

A Custom Install If you need a custom install, follow these steps: 1. Click the Customize button, shown in Figure 1-3.

13

14

CHAPTER 1 ■ BEFORE YOU BEGIN

Figure 1-3. Click the button for the type of install you wish to perform. 2. This will launch the dialog box asking you to choose the location on your system to install Expression Web. Use the Browse button to navigate to the location where you want Expression Web to be installed, as shown in Figure 1-4.

Figure 1-4. Use the Browse button to choose your install location.

CHAPTER 1 ■ BEFORE YOU BEGIN

■Note This will be your only chance to choose your install location. If you use the Install Now button and then try to go back to change the install location, you will get an error and be unable to complete your install.

3. The last choices you will have are to change the default options installed. One change you may wish to make at this stage is to install the ASP.NET web server now instead of on first use, if the web server you will be hosting on offers ASP.NET 2.0.

Figure 1-5. Install the VBScript editor for writing Classic ASP

4. If you are short on hard drive space, you may also change the tools you do not anticipate using to install on first use. 5. Use the Continue button to complete your install.

15

16

CHAPTER 1 ■ BEFORE YOU BEGIN

Taking Your First Look at Expression Web If you have never used a web editor before but have used Windows or one of the Microsoft Office programs, parts of Expression Web will look familiar. You will see the same type of menus across the top and a format toolbar like you see in other Microsoft programs. The Expression Web interface consists of a series of toolbars, status areas, and task panes. By default, it looks Figure 1-6.

Figure 1-6. When you first open Expression Web, it will look like this.

To work effectively in Expression Web, you will need to become familiar with all of the numbered areas in Figure 1-7.

CHAPTER 1 ■ BEFORE YOU BEGIN

Figure 1-7. Sections of the Expression Web interface The Expression Web interface is divided into the following areas: 1. Menu bar: The menu bar follows Windows standards and consists of File, Edit, Insert, Format, Tools, Table, Site, Data View, Task Panes, Windows, and Help options (see Figure 1-8).

Figure 1-8. Expression Web’s menu bar uues the familiar Windows menus. 2. Format toolbar: While the Format toolbar (see Figure 1-9) may look like the one in Microsoft Word and FrontPage 2003 (and earlier versions), it behaves quite differently from either of those programs by writing styles instead of applying font tags. Unlike with older web editors, if you repeat your format actions on subsequent sections of text, Expression Web does not create a separate style but applies the class created in the first instance to your new selection.

Figure 1-9. While this may look like a typical Microsoft formatting toolbar, using the buttons on it will generate styles, not apply font elements.

17

18

CHAPTER 1 ■ BEFORE YOU BEGIN

3. Folder List: The Folder List is technically a task pane, but the function it serves in your site is so important that the Folder List deserves its own section number. This is where your local site files are shown. Every page, image, or other file should be listed here in the same folders as on your production website. Use it to open files, or drag images, Dynamic Web Templates (DWTs), stylesheets, and other items to be displayed in or attached to your pages. Until you create a local website, the Folder List will be empty, as shown in Figure 1-6. Once your site is created, it will look more like the one shown in Figure 1-10.

Figure 1-10. The folder list provides you with an outline of all the files in your local website.

4. Task panes: Each of the task panes has one specific function. There are 18 task panes and one entry to reset your Expression Web interface back to the default layout. The six most commonly used task panes are open by default. These are shown in Figure 1-11.

CHAPTER 1 ■ BEFORE YOU BEGIN

Figure 1-11. Task panes displayed by default in Expression Web

The following task panes are open by default in Expression Web: a. Folder List: See item 3. b. Toolbox: Drag HTML elements and ASP.NET controls from the toolbox to use on your web pages. c. Tag Properties: Holds two tabbed properties task panes: • Tag Properties: Displays the attributes available for the HTML element or ASP.NET control that is selected on the open page as well as any events associated with that item. • CSS Properties: Displays the property and values of the chosen element including those properties inherited by the element. d. Apply Styles: Holds two tabbed styles-related task panes: • Apply Styles: Here, you can choose from available styles to apply to an element or section of text, and you can create new styles. The styles available will be shown in the Apply Styles task pane with the style settings applied, so that you can see what the style will look like when you apply it. • Manage Styles: This pane allows you to move styles between your document and an external stylesheet as well as create new styles.

19

20

CHAPTER 1 ■ BEFORE YOU BEGIN

5. Document tabs: These show you the pages you currently have open. A tab will be added for Web Site view once you have created and opened a website, as shown in Figure 1-12. In the Web Site view, you will see a top-level representation that matches your collapsed Folder List until you connect to your Internet server to publish your site. Once you have connected to your remote site, the publishing interface will become the default view for the Web Site tab.

Figure 1-12. The document tab bar shows the pages you have open along with the Web Site view when you are connected to your web server.

6. Quick Tag bar: Acts like a document breadcrumb map showing you where you are in the document’s structure. Using the bar, you can select and edit the HTML elements as shown in Figure 1-13.

Figure 1-13. Using Quick Tag shows you the document structure and lets you manipulate the elements.

7. Document window: This is where you create your web pages using one of the following three views, which are shown in Figure 1-14: • Design: This view, shown with a blank page in Figure 1-6, renders your page according to the doctype chosen and is a close approximation of what the browser displays. Design view rendering has improved so that there is no need for a separate Preview view inside Expression Web. • Split: Shown in the Figure 1-15, this is the recommended view, since it allows you to see both the code and the way the code renders in a modern browser. • Code: This view, shown in Figure 1-14, lets you view only the code, which, unless you come from a development background, may be difficult for you to visualize.

CHAPTER 1 ■ BEFORE YOU BEGIN

Figure 1-14. From left to right, the three document views are Design view, Split view, and Code view. I recommend working in Split view.

Figure 1-15. Using Split view for your Document window lets you see both code and design at the same time.

21

22

CHAPTER 1 ■ BEFORE YOU BEGIN

8. Document window options: Below the Document window is a context-sensitive set of options for the Document window. The default view when Expression Web is first opened is shown at the bottom of Figure 1-11. When you have a local Web Site open without a page open in the Document window, you will see a page that looks like the Folder List with file details such as you would see in the details view of Windows Explorer. If you have connected to your web server to publish your site, you will see your local and remote servers, as shown in Figure 1-16.

Figure 1-16. The web publishing interface will appear under the Web Site tab in the Document Window with related options of Reports and Hyperlinks in the Document Window’s options. 9. Status bar: This is the last section of the Expression Web interface. As the name implies, it lets you see page status and program options. In Figure 1-17, you can see that Visual Aids are turned on; Style Application is automatic; and the Document window design section is a narrow 354 pixels wide. Ideally, the design section of Split view (and of the whole page in Design view) would be the width you want for your page, but in this case, I narrowed the space available to get the screenshot you see in Figure 1-17. The remaining information in the Status Bar tells me the doctype and Cascading Style Sheet (CSS) version the page is using.

CHAPTER 1 ■ BEFORE YOU BEGIN

Figure 1-17. The Status bar provides you with information about your Expression settings and your web page.

Summary In this chapter, we have made decisions concerning the purpose of the website you will be creating and your target visitor. We looked at when you need a domain name and at commercial web hosting versus using third-level hosting without a domain. These are important decisions you should make before you begin creating your website. Next, we installed Expression Web and learned how the design surface helps us create better web pages. Now that you are familiar with the interface, it is time to create your first website!

23

CHAPTER

2

Taking Your First Steps B

efore you begin you must create a local website. In this chapter, you will get started by creating a local website and a home page for your site. Along the way, you will be learning the menus and features in Expression Web that will make working on your site easier.

Creating a Local Website Before you create a single web page in Expression Web, you need to create a local website. Otherwise, Expression Web cannot manage links among your web pages and items you link to in your web pages. To begin, you will create a new one-page website. The best way to do this is from the File menu.

File Menu In the File menu, you have all the normal functions you expect to see on any Windows program with some others that are specific to Expression Web (see Figure 2-1).

Figure 2-1. The File menu contains web-specific options in addition to the standard Windows file options.

25

26

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

There are several items of special interest to you on the File menu: • New: Choose the type of new web page or local website you want to create. • Preview in Browser: See what your page will look like to your visitors and not just in Expression Web. • Publish: Move your web pages from your local computer to your web host.

New Create new websites and new pages with the New option (see Figure 2-2).

Figure 2-2. The New option is the one that you will use to create your first website. To create a local website, you would use File ➤ New ➤ Web Site. For now, you will be concerned only with the New Page and New Web Site options. Later in this book, you will be using the New CSS options. The first exercise in Expression Web is to create a local website (see Exercise 2-1).

■Caution Always work in a local website, never on just an individual web page in your site!

WHY A LOCAL WEBSITE IS NECESSARY A website is a collection of pages with interrelated links. One of the strengths of Expression Web is the ability to manage those links, but it cannot manage links in a vacuum. When you create and use a local website to hold your web files, Expression Web will maintain metadata showing how the files are related to each other. This means that you will be able to move files from one folder to another and let Expression Web manage the relative file paths so you can organize your files and folders to match the needs of your site.

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

Exercise 2-1. Creating a New Site and Page In this exercise, you will create a new website and a web page.

Creating a New Site 1. Create a new blank website using the File ➤ New ➤ Web Site option, as shown in Figure 2-3. 2. In the dialog box that appears, select the Empty Web Site option from the center column.

Figure 2-3. General website choices include a one-page website, an empty website, and the option to import a website from the Internet or another location on your hard drive.

■Note You should change the location where your new site will be created by either typing in the file path or using the Browse button to go to the folder you want to create your new site in. Once you are in the folder, add the name of the new website to the end of the file path in the dialog box.

3. After you change your site location and name, click the OK button. You will see the site appear in the Folder List task pane (see Figure 2-4).

Figure 2-4. The file path to your newly created website will appear at the top of your Folder List.

27

28

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

Creating a New Web Page 1. Click File ➤ New ➤ HTML to create a single new web page. I recommend using Split view whenever you are working on your web pages so that you can see how Expression Web is writing your code.

■Note Do not select File ➤ New ➤ Page, as shown in Figure 2-2. This opens the dialog box to the Page tab, shown in Figure 2-3, instead of the Web Site tab. You will examine the Page tab options later.

A page will be created with the code, as shown in Figure 2-5.

Figure 2-5. The default web page created by Expression Web 2. Right-click the Design view section of the document window, and select Page Properties. The default page name will be Untitled with a number that will increment with each new page, as shown in Figure 2-6. Change the page title to My Home Page, which I used in my example, or the name of your choice if you prefer.

Figure 2-6. The Page Properties dialog allows you to add a page title and other elements in one place.

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

The page description is displayed by some search engines when your page is returned in response to a search, while keywords may help other search engines categorize your pages. If you choose to use these elements, keep the text to less than 200 characters. 3. Add one line of text in Design view that says, “This is my first web page using Expression Web.”

■Note Your web host will have a default document name, usually index.html or index.htm, which will be served when a person types in your domain name.

4. Use File ➤ Save to bring up the Save As dialog box, shown in Figure 2-7. By default, Expression Web will name the file using the page title, replacing the spaces with underscores. 5. Change the name by typing over it in the “File name” field. For the exercises in this book, I will be using index.html as the default page. If your host uses a different name, please substitute it whenever you see index.html.

Figure 2-7. The Save As dialog box will appear when your page has not been previously saved.

6. Your folder list should now include index.html. The final step in this exercise is to use F12 to preview your page in your default browser.

29

30

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

FILE AND FOLDER NAMING The name of a file or folder is determined, in part, by the type of server you are using. Linux or other Unixbased servers make up the majority of production web servers and backbone servers such as the Domain Name System (DNS), which resolves domain names, and gateway computers, which manage the connection between you and your ISP’s connection. These servers are case sensitive and, unless you are on a closed intranet, your request for a web page will certainly pass through a Linux server somewhere between your computer and the hosting web server. You should always have a page with the name your host uses as its default in every folder on your site. Otherwise your visitor may get a list of all the files in your directory.

Use Meaningful File and Folder Names Not only does using about_us.html or green-tank-shirt.html make it easier for you to know what is on which page of your site, but meaningful names can help your site fare better in search engines. While Windows servers are not case sensitive, XHTML and XML are, so you might as well start with good practices. My recommendation is to use all lowercase letters in file names and to use hyphens to separate words as needed.

Do Not Use Spaces Because Linux servers will break a URL at a space, most web servers and browsers encode a space as %20, but this is not foolproof. To be safe, never use spaces in your file names. Unix-based web servers and e-mail clients will break the URL at a space, which can cause your links to return a 404 (file not found) error.

HTM vs. HTML What is the difference between the file extensions .htm and .html? The fact that both exist is a legacy from DOS, which had a limitation on file names of 8.3, that is, an eight-character file name plus a three-character file extension. Since DOS and by extension Windows 3.11 or lower could not understand the four-character .html extension, people using DOS or Windows who wanted to be able to edit or create web pages needed to use .htm. Viewing pages with the .html extension was not typically an issue, since DOS browsers would drop anything after the first three characters. It does not matter which extension you use, but pick one and be consistent.

Pick a Case How many separate pages are there in the following list? • AboutUs.html • Aboutus.html • ABOUTUS.HTML • aboutus.HTML • aboutus.html

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

The answer depends on what type of server we are on. On Windows, there is one file, but on a Linux server, there are five—each and every one of these files is different. If the browser requests aboutus.html and only ABOUTUS.html resides on the server, your visitor will get a 404 error. Since we are working on Windows with Expression Web, which is not case sensitive, it is smart to pick one naming convention and stick to it. I recommend using all lowercase. Because XHTML is case sensitive, you will be working with lowercase element names (required) and lowercase attributes (also required), so you might as well continue the theme with lowercase values. If you happen to come from a programming background where camel case (multiple words run together with the first letter of each inner word capitalized like multipleWords) is the norm, go ahead and continue to use camel case, but make sure you are consistent.

Be Consistent in Your Naming Conventions Being consistent in your naming conventions means more than being consistent with the case of your file and folder names. It also means keeping the names of folders and pages you will create in more than one website the same; don’t use images in one and pictures in another. I like to name the primary stylesheet for a website with the site name. For example, if I am searching for a specific stylesheet, I can tell at a glance that foundationewd.css is the stylesheet for foundationewd.com and not have to guess to which website site.css or style1.css belongs. By the same token, I will know that a page named contact-us.aspx is a contact page while faq/sales.html will have the frequently asked questions page for sales. The road to 404 errors is paved with inconsistencies.

■Note You should never work on web pages in Expression Web outside of a website, or your links may not resolve correctly when you move or add files to your website.

Preview in Browser No matter how good or bad a page looks in Expression Web’s Design view, it may not look the same when viewed in the browser. If the browser is standards compliant, your page should appear the same as in Design view, but we all know that no browser is 100 percent compliant. Every browser has one or more display quirks. In part, these quirks exist because the W3C specification is not detailed in every instance. For example, to determine the width of a container, should the width include the amount of padding, the thickness of the border and margin, or just the content? This decision was left to the browser makers. Needless to say, the browser makers did not all choose the same method; as a result, it is always best to test in a real web browser. To preview in your default web browser at your default browser settings, all you need to do is use F12. By using the Preview in Browser fly-out menu (found in the File menu), you have many more choices, as shown in Figure 2-8.

31

32

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

Figure 2-8. Expression Web lets you choose the browser and resolution for viewing. Expression Web will always look for Internet Explorer and will add it to your preview list when it is not the default browser. Since my default browser is Firefox, I see Internet Explorer listed as a separate option. Although I have Opera installed on my system, it is not my default browser, so Expression Web did not add it to my browser list. Other browsers you have installed will need to be installed using the Edit Browser List option (shown in Figure 2-9) at the bottom of the fly-out menu.

Figure 2-9. Make sure that you have the major browsers for your operating system installed, and add them to your preview list. Adding browsers is as simple as clicking the Add button, following the dialog box prompts, and navigating to the location of the browser.exe file to add the browser to your list. Window Size You may have noticed that when you choose to preview in one or multiple browsers, you can also select from common screen resolutions for previewing your pages. Your web pages may look different when viewed at different screen resolutions, but your site still needs to look good regardless of the browser size.

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

I would recommend that you preview at 800×600 and 1024×768. Very few people are using 640×480. To preview in a browser locally, you may need to save your web page before it will be displayed. As long as you have not closed the page in Expression Web, you may still use Edit ➤ Undo or Ctrl+Z to undo your page changes up to the last 30 changes since your page was opened.

ABOUT BROWSERS While Design view gives you a good representation of what your page will look like according to the doctype stated in the code (the default is XHTML 1.0 Transitional) full stylesheet support, no browser available is 100 percent standards compliant. For that reason you should get in the habit of using F12 to preview your web pages locally in your default web browser.

Testing in Multiple Browsers At minimum, you should have the default browser for your operating system. Since you are using a web editor that runs only on Windows XP or Windows Vista, you have either Internet Explorer 6 or 7 installed. This will be your default browser unless you have changed it. If possible, you should have both, since only those using Windows XP with Service Pack 2 or later and Vista will be able to use Internet Explorer 7. Older versions of Windows will be limited to Internet Explorer 6. Running both versions of Internet Explorer requires two separate computers or a Virtual PC with another Windows operating system installed. Unfortunately, unless you have access to more than one computer or can run Virtual PC, you will be able to test in only one version of Internet Explorer. You can download Virtual PC free from Microsoft at http://www.microsoft.com/windows/virtualpc/default.mspx. Better yet download and install one or more of the following browsers: • Firefox: http://www.mozilla.com/firefox/ • Opera: http://www.opera.com/ • Netscape: http://browser.netscape.com/ Users of Firefox, Mozilla, Opera, and Netscape tend to update to the latest version, so you do not typically need to install older versions of those browsers. This will allow you to preview in multiple browsers, since you will not know what browser your visitor will be using. If possible view your pages from a Mac using Safari in addition to the browsers listed previously.

Publish A website that never makes it to the Web will not accomplish your goal. Since publishing is such an important part of creating web pages, I will cover this topic in detail once you are ready to publish pages. You will want to publish the single page you created. Since you may not have published a web page before in any web editor, I will cover File Transfer Protocol (FTP) and FrontPage Server Extensions (FPSE) publishing before going any further.

33

34

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

To begin the process of transferring the web pages you create locally to a production server, you use File ➤ Publish Site. This launches the Remote Web Site Properties dialog box, shown in Figure 2-10. Your commercial web host should have provided you with the information you need to publish your website to your web space. If you are using the web space provided by your ISP, please check their FAQs before you begin the publishing process.

Figure 2-10. Choose the publishing method supported by your web host.

Remote Web Site Properties The first thing you will notice in Figure 2-10 is that there is a variety of options you can use to publish your site. They are as follows: • FrontPage Server Extensions (or SharePoint Services) • WebDav • FTP • File System Most web designers will use standard FTP as their publishing method. I recommend using the built-in FTP client to publish your pages, because it simplifies the transfer and synchronization of files between your local copy and the one on your production server. However, if you manage a large number of websites, you may prefer to use a third-party FTP program, since the one in Expression Web does not remember user IDs and passwords for FTP connections.

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

As mentioned previously, we will look at FTP and FPSE. WebDAV is rarely used, but if you have that option, just follow the prompts. The File System option is useful if you’re publishing across a network. Using FTP Follow these steps to use FTP to publish your site: 1. Select the FTP radio button. 2. Type the location of your FTP server. This is usually the site name proceeded by ftp://, but it may vary, which means you need to check the documentation provided by your web host.

■Note In most cases, when you use FTP to connect to your website, you will be entering at a level above your public folder or directory. Common names for this root folder, which is displayed to your web visitor, are public_html, www, or webroot. Consult the instructions you have received from your host.

3. Click the OK button to launch the login credentials dialog box, shown in Figure 2-11.

Figure 2-11. This credentials box will be the same whether you are using FTP or FPSE to publish.

Using FPSE If you have FPSE installed on your web server, you may use it to publish to your production site. Since Expression Web will remember your user ID/password when you publish with FPSE and not when you publish with FTP, you may find this method more convenient if your web host supports FPSE publishing. If you select the radio button for FrontPage Server Extensions, the “Remote Web site location” field will change to look like the one in Figure 2-12.

35

36

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

Figure 2-12. The remote Web site location changes to reflect an HTTP address. Notice that with FrontPage Server Extensions you publish using HTTP. On some corporate networks FTP is blocked, but you can still publish via HTTP, since it uses the same port as the one used to view web pages (80) instead of the blocked FTP port (25). Publishing Your Web Page Once you have connected to your website, you will see a split screen with your local website on the left and your remote website on the right. As shown in Figure 2-13, there may be files in your remote site even before you publish any files. Typically, your web host will have a default placeholder page that says “coming soon” or some other generic text that you will need to replace. You may also have folders such as cgi_bin or aspnet_client.

■Caution Do not delete or change any folders that your web host has preinstalled without checking with your host first, or your website may not function properly.

Expression Web will keep track of the publishing status of your web pages. Figure 2-13 shows a question mark (?) next to the index.html file in each location, because Expression Web is able to tell that the two pages are not the same based on file dates and other metadata. To synchronize your website, you can use the radio buttons at the bottom to publish your local website to your server, transfer pages from the remote to the local (useful if you are working on a site from a new computer or program), or synchronize pages, which will publish newer files from one site to the other. To transfer all the changed files in your website between your local computer and your website, select the appropriate radio button in the bottom “Publish all changed pages” section, and then click the Publish Web site button. If you want to transfer just one file, you may highlight it in the appropriate site and use the arrow between the two site windows to transfer or replace the one in the other site. In Exercise 2-2, you’ll learn how to publish your web page.

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

Figure 2-13. You web host will have preinstalled files and/or folders when you first connect.

Exercise 2-2. Publishing Your Web Page In this exercise, you will publish the web page you created in Exercise 2-1. Make sure that you have the information from your web host available before you start this exercise. 1. For the local website you created in Exercise 2-1, make sure you have saved your index.html file. While you can publish a file that is open in the document window, only the last saved version will publish. 2. From the File menu, select Publish. 3. Select FTP or FPSE, depending on your web host options. If using FTP, make sure you have the correct folder name in the FTP Directory text box for the folder that is the root of your public website. Check your hosting documentation for the correct folder. 4. Type your user ID and password in the Credentials dialog box. 5. Click the Synchronize button to publish your local website to your server. You should get the Conflicts dialog box shown in Figure 2-14. Choose Overwrite Remote Files, since you will be replacing the generic placeholder home page.

37

38

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

Figure 2-14. This conflicts warning will appear whenever Expression Web is unable to tell the status of individual files.

■Note When you have successfully synchronized, any files or folders on your remote site will have been transferred to your local site. Generally, these are scripting folders that you should not be editing. If you rightclick the folder in the folder list and select Convert to Web, you will be able to synchronize files in the future without publishing the folder or its contents.

You should no longer have a conflict between the two index.html versions, and any scripting or other hosting folders will have a globe icon inside their icon on your local site to let you know that those files will not be published when you synchronize files in the future, as shown in Figure 2-15.

Figure 2-15. Notice the globe in the local aspnet_client folder, which marks it as a separate subweb not to be published.

Congratulations, you have published your first web page!

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

Edit Menu The Edit menu, shown in Figure 2-16, has all the standard Windows edit commands: • Undo/Can’t Undo: Lets you undo the last action. It’s grayed out in Figure 2-16, since there are no actions to undo. • Redo/Can’t Redo: Lets you restore your last action after using Undo. • Cut, Copy, Paste, Paste Text, Delete, Select All, Find, and Replace: These are the standard Windows commands. • Incremental Search: This search option finds as you type, instead of searching for a full word or string. • Go to Bookmark: This will open the Bookmark dialog box. Note that this changes to Go to Line if you are in Code view. • Quick Tag Editor: Opens the Quick Tag Editor, shown in Figure 2-17, which can be the easiest way to change a tag. • Check In, Check Out, and Undo Check Out: These options are useful for teams working on a site; they can help to prevent accidentally over writing changes made by others. • Code View and IntelliSense: I discuss these options in more detail in the following section.

Figure 2-16. The Edit Menu has all the traditional Windows options along with a few that are unique to Expression Web.

39

40

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

Figure 2-17. The Quick Tag Editor floats on top of the Document window and allows to you make quick edits.

Edit Code View If you are like me, you want to see the code that is being created, whether it is code Expression Web creates for you or code you write yourself. The Edit ➤ Code View section, shown in Figure 2-18, has actions that can make it easier to work in Code view. You will be able to see these options only when you are using Code view or your cursor is in the Code section of Split view. While it is best to set your default Code view configuration using Tools ➤ Page Editor Options, some of the options on this menu can help your workflow.

Figure 2-18. The Code view submenu is divided into sections for code formatting and for managing HTML element tags, code bookmarks, and hyperlinks.

Tag Management Section This section of options allows you to work with your HTML tags using the following options: • Select Tag: Selects the opening and closing tags as well as everything in between • Find Matching Tag: Takes you to the closing tag for the element selected

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

• Select Block: Selects the nearest block level element • Insert Start Tag: Inserts opening and closing angle brackets, < >, to add an HTML element tag • Insert End: Inserts a pair of angle brackets with the closing slash, , to close a tag • Insert Comment: One of the most useful of the tag management section; allows you to insert comments to yourself so when you have not worked on a page for a long time you will know why you did what you did

Bookmark Section The following options are not for bookmarks in your HTML; instead, they allow you to create bookmarks in your code to quickly jump from one section to another in Code view: • Toggle Bookmark: Lets you set a temporary bookmark in Code view, which can be helpful when trying to troubleshoot errors whether in your code or in your stylesheet. These bookmarks are temporary and will be deleted when you close the web page in Expression Web. • Next Bookmark and Previous Bookmark: Moves forward or backward between bookmarks in Code view. • Clear Bookmarks: Just as it says, it removes all the Code view bookmarks when you are finished troubleshooting.

Hyperlinks Section Like the bookmark section, these options are only for Code view. They let you move between the CSS and JavaScript files that are linked in to your page.

■Note Microsoft also uses the term “bookmark” to refer to in-page links for your visitors to navigate within your web page that are added via the Insert menu. The code for a permanent bookmark is back to top.

Edit IntelliSense Similar to the Edit ➤ Code View options, your cursor must be active in page code and inside an HTML element that has IntelliSense options for the Edit ➤ IntelliSense section to become available. These options are options you would normally use the keyboard for, since using Ctrl+spacebar for code completion is easier than using Edit ➤ IntelliSense ➤ Complete Word. The most useful option here is to trigger the code snippet list for you to choose a code snippet to insert. See Chapter 3 for more information about code snippets.

41

42

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

View Menu The View menu, shown in Figure 2-19, has many options worth paying attention to, since they can help you troubleshoot problems.

Figure 2-19. The options on the View menu are unique to Expression Web. For now, leave the default settings on the View menu, but I’ll quickly run through the options so you know what they do. • Page: This lets you set the display mode for the main document window. The options are Design, Split, and Code. • Visual Aids: These options, shown in Figure 2-20, allow you to set how certain structures are displayed in Design view.

Figure 2-20. Visual Aids are useful but can change how your page renders in Design view. Turning them off gives you a browser preview. Visual Aids allow you to see and modify code elements in Design view instead of working directly in code. The choices follow: • Block Selection is the default. When you select an element in Design view, the element boundaries will be outlined, and the HTML element will be identified at the top-left of the outlined area.

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

• Visible Borders shows a dotted line around elements such as table cells when the element does not have visible borders set in the code. • Empty Containers is a quick way to show empty elements on your page. This is most useful when the page is not displaying as you expect—frequently an empty element is on the page, which typically happens when you forget an opening or closing element when you delete or edit text. • Margins and Padding gives a red outline to the containers. By dragging the outline as shown in Figure 2-21, you can change the margin around an HTML element. If you press Ctrl and drag, you will change the amount of padding around your element.

Figure 2-21. To change the margin or padding, make sure you are not over one of the resize handles. • CSS Display:none Elements gives you a quick way to view elements with the CSS property of display: none. Items with display: none will have the space they occupy collapsed by the browser. • CSS Visibility:hidden Elements allows you to toggle to display elements hidden using visibility: none, the other method of hiding elements using CSS. The space these elements occupy will not collapse in a browser. • ASP.NET Non Visual Controls will show a rectangle as a placeholder for ASP.NET controls. • ASP.NET Control Errors will provide you with an error message if there is a problem with the control, such as not being able to connect to a data source. • Show Template Region Labels displays an orange outline by default when you are in an editable region. This option will show all editable regions on the page, not just the active one. • Formatting Marks: This menu will be grayed out until you have turned on Show. Once you have turned on Show, you can choose which of the marks you would like to use. “Formatting marks” is a slightly misleading term, since this section includes hidden form fields, script elements, and CSS properties. • Ruler and Grid: Many people, especially those who are used to designing for print or who have been using tables for page layout, use rulers for reference. The options are self explanatory.

43

44

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

• Tracing Image: Some designers will create a mock-up or comp in PhotoShop or another graphics program and then use the image as a visual aid in laying out their web page. If such an image is part of your workflow, this is where you would select and place the image. Images used in this manner will be displayed in Expression Web but not on your web pages. • Page Size: This allows you to quickly see how your page layout will look at the most common screen resolutions in Design view. While this is not a substitute for checking in a real browser, it is useful for a quick check. • Folder List: This opens the Folder List task pane if it is closed. • Quick Tag Selector: This opens or closes the Quick Tag bar. I recommend that the Quick Tag bar always be displayed. • Toolbars: This provides you with a list of the toolbars available and allows you to open or close each one. Toolbars that are currently open have a check mark next to them. One toolbar that is not open by default that I find useful is the Styles toolbar. Explore the toolbars available on your own to see which ones you find useful. • Refresh: This is the same as pressing F5 on your keyboard to refresh Expression Web. If you have added files to your site through Windows Explorer or by saving a file directly to your website from another program using this option (or pressing F5) will make it appear in your Folder List task pane.

Insert Menu Most of the functions on the Insert menu, shown in Figure 2-22, are duplicated in either the Toolbox task pane or the Behaviors task pane, both of which offer more options than those in the Insert menu. These elements will be explained as you use them or when you explore the Toolbox task pane.

Figure 2-22. The HTML and ASP.NET controls duplicate a fraction of the elements available on the Toolbox task pane.

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

These are the items on the Insert menu: • Hyperlink: Opens a dialog box to insert a link to another page, a document, a file, or a bookmark on the same page. • Bookmark: Opens a dialog box to insert an anchor element: to mark a specific section of the page for a hyperlink. • Picture: Inserts a picture and sets the alt attribute, which is the text that is displayed if the image does not load or your visitor is unable to see images. • File: Imports content into your web page from another HTML document, a Word file, or one of the other file types listed in Figure 2-23. • Interactive Button: Creates the appearance of a button and rollover effects as you mouse over the links created. • Symbols: Lets you add copyright, trademark, and other items from the symbol menu.

Figure 2-23. The Insert menu’s File option allows you to browse to files on your computer with the extensions shown to insert them as content on your page.

■Note In most cases with RTF or Word documents, the formatting will be imported as well. You may need to clean up the code after you have imported content using this method.

Format Menu You will frequently use the Format menu, shown in Figure 2-24, since it contains one of the most important commands for bringing in content from other sources such as Word files: Remove Formatting. This lets you quickly remove the outdated and bulky code many word processing and other programs add for presentation so you can apply the look and feel of your site to the content. Here, you have options to create and apply styles to your page, to add behaviors such as rollovers, and to use DWTs and master pages to keep the look and feel of your site consistent from page to page. Although many of the options on the Format Menu are available in task

45

46

CHAPTER 2 ■ TAKING YOUR FIRST STEPS

panes, the Remove Formatting, Dynamic Web Template, and Master Page options are most frequently used from the Format menu.

Figure 2-24. Format menu options include page and tools for keeping your pages consistent within your site. While some of the options in the middle section of the Format menu (starting with Font and ending with Borders and Shading) look like their Word or FrontPage counterparts, they do not work the same. Instead of creating bulky inline font markup that is repeated every time you use the buttons, a style is created and reused. This automatic reuse of existing styles is one of the best features in Expression Web, one that will help you create pages that load faster. In Chapters 5 to 7, I will cover using a CSS to format your page display and layout.

Summary You should be familiar now with the basic menu functions and be able to create a local website and a basic HTML page. You have explored the menus that are common in all Microsoft programs, and you have seen where Expression Web–specific additions to the Microsoft standard menu commands exist. Other than the Window and Help menus, the rest of the menus are task or program specific. Remember that you should never work on individual pages in Expression Web without opening the local website or your links, and other page features may break. Throughout the remainder of this book, you will be using the options on these menus and related task panes to create a fully functional, attractive website. In Chapter 3, I will show how to configure Expression Web to make that task easier by changing some of the defaults in Application Options, Page Editor Options, and Site Settings.

CHAPTER

3

Starting Off Right: Configuring Expression Web I

n the last chapter, you created a local website using the default settings. In this chapter, you will change the default settings in Site Settings and Page Editor Options to improve your workflow. You’ll configure Expression Web to make your website easier to maintain by using classes that improve workflow, instead of inline styles and program defaults.

Using the Tools Menu Like the Format menu, the Tools menu has many useful options (see Figure 3-1). You will probably need to set some of the options here only once, but they are significant. They are Application Options and Page Editor Options, which are important enough to warrant a detailed discussion of the options on their tabs. Like others we’ve discussed, this menu can easily be divided into sections. You’ll start with the general tools you find in most Microsoft programs.

Figure 3-1. The Tools menu is where you set Expression Web default options, as well as a few content and reporting tools.

47

48

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

General Tools Section The general tools are as follows (the first two are shared with Office 2007 and will be installed even if Office 2007 is not present): • Spelling: This option has a submenu that allows you to run the spell-checker and set spelling options, which are self-explanatory. • Thesaurus: This option is useful only if you are writing content. • Set Language: All of your web pages should have default language settings. However, sometimes you will use more than one language on a page. Use the Set Language option to indicate you have changed the language within a page. For example, you might have the French phrase c’est la vie in the middle of your content. Normally, to tell the browser and any screen reader or search engine about the language change, you need to wrap the text in a span with the new language identified. In my example, the code to change the language would be as follows: c'est la vie. By highlighting the text in Design view and using Tools ➤ Set Language, you can choose the language without needing to write the language code yourself, as shown in Figure 3-2.

Figure 3-2. Changing the language of a section of text is as simple as choosing the correct language from the scrolling text box.

Reports Section This section is where you can run reports that let you know what problems, if any, there are on your page. Here, you will just see what reports are available. In Chapter 12, you will be using the Accessibility Report. The reports are as follows: • Accessibility: Checks for Section 508 and Web Accessibility Initiative (WAI) compliance issues with the page. Please note that while the checker can provide a basis for determining whether the page is accessible or not, no automated checker can determine that accessibility has been achieved.

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

• Compatibility Checker: This report is more or less a local validator for well-formed HTML/XHTML and CSS code. Since you should always have a doctype declared on your pages, I recommend using the Checkbox control to base the check on the doctype specified in the page. You can use this checker as you are creating pages, and the result should be the same as you get by using the W3C validator, which you should also run once you have published your pages. • CSS Reports: This option lets you determine what styles are or are not used within your site as well as checking for errors. Sometimes when you have been working on a site, styles accumulate that you end up not using. Many people prefer to remove these unused styles to both tidy up their stylesheets and reduce the page weight. Notice that you have the ability to run checks on the entire site or on selected pages.

Optimize HTML Selection The options in the Optimize HTML dialog box, shown in Figure 3-3, are both useful and dangerous. Like in the Format ➤ Remove Formatting selection, you can clean up legacy code as well as data from Word files and other imported files with tags. These useful options are located in the Remove Unused Content and Remove Generated HTML sections. If you have content imported from Word or legacy FrontPage sites, I recommend using all the options in these two sections. If you have an external stylesheet applied, detach the stylesheet before removing Unused Styles.

Figure 3-3. The Optimize HTML dialog box is one way to clean up imported code or legacy sites.

49

50

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

OPTIMIZATION OPTIONS NOT TO USE I do not recommend using the Remove Whitespaces options. If you use them, your code will run together, making it very hard to troubleshoot or even read. Some people feel that removing whitespace will protect their code, which is not true since most web editors easily reformat the code.

■Tip In Expression Web, simply right-click while you’re in Code view, and select Reformat HTML to restore text indenting.

Another reason some people remove whitespace is to eliminate a few bytes of page weight. You will not reduce the weight enough to make it worth the time it takes to reformat the code when you need to work on the page again. The other section I don’t recommend using, or at least using with extreme caution, is the Remove Comments section. HTML comments are something that I encourage you to use, since on many occasions, you might not look at a web page for long periods of time and work on other projects in between. When you return to your page, you might not remember why you did something. HTML comments will remind you why you wrote the code you did. Many designers use comments to identify structural parts of the page. Script comments can serve the same function, but if you are using third-party scripts, they might require you to leave attribution comments in the code. Older browsers or those that do not have JavaScript enabled will keep the text of the script from being displayed in the browser. For these reasons, I recommend that you leave comments in your code.

Program Management Expression Web is highly extensible. Add-ons are available from Microsoft and third-party add-on makers that will give your site more features. Some of the add-ons might be downloaded for free and others purchased. Add-ons available at the time of this writing include PayPal buttons, shopping carts, form tools, Flash players, task pane managers—and more are becoming available all the time. The tools in the program management section allow you to create and use add-ins: • Macros: The fly-out menu here allows you to run macros you have created or launch the Visual Basic Editor or Microsoft Script Editor. • Add-Ins: Third-party tools and applications you can use in Expression Web can be accessed here. • Customize: This lets you customize the Format and other toolbars.

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

Preferences Section In this section of the Tools menu, you set defaults for how Expression Web will start up, handle different file types, interact with other programs used in web design such as graphics programs, and handle coding options.

Application Options Clicking Application Options launches the dialog box shown in Figure 3-4.

Figure 3-4. By default, Expression Web will make itself your HTML editor, and it will automatically open the last website you worked on when it is launched.

The General, Reports View, and FTP Tabs The settings under the General, Reports View, and FTP tabs rarely need to be changed from the defaults. However, you will need to use an external graphics editor, since Expression Web has very limited image-editing capabilities, and when you double-click a graphics file, Expression Web will open Microsoft Paint to edit images. If you do not have a graphics program, such as Expression Design, Photoshop, or Fireworks, you can download Paint.NET from http://www.getpaint.net/index.html. Although this is not as full featured as the others named, it is a good free graphics program. Later in this chapter, you will be adding a thirdparty graphics editor and setting the editor you add as the default. The Configure Editors Tab Figure 3-5 shows the Configure Editors tab. Notice that Expression Web correctly picked up that my default graphics editor is Fireworks. If you have only one graphics editor and it is correctly identified, you can skip the remainder of this section.

51

52

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

Figure 3-5. By selecting a file extension from the left-side list, you can check what will happen when you double-click a file with that extension in Expression Web. If you have more than one editor or if the editor you’d like to use is not marked as the default, follow these steps to select the editor: 1. To begin adding a new editor, locate the file extension that you want to change to a different editor; in this case, select the entry for “jpg, jpeg, gif, png” from the Extensions section of the dialog box (on the left side), as shown in Figure 3-6.

■Note If you want to use different editors for each of these extensions, you could delete each default group and add each extension back, either individually or grouped to fit your preferences.

Figure 3-6. To add an editor, click the file icon button.

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

2. Next, select the folder icon above the Editors section, or if you prefer keyboard shortcuts, press Alt+N, as shown in Figure 3-6, to launch the Open With dialog box (shown in Figure 3-7).

Figure 3-7. Select the program you want to add. 3. In the Open With dialog box, you can choose which editor you want to use. If the program is listed in the Open With dialog box, select the program and click OK. The editor I want to add, Paint.NET, is not listed, which means I will need to use click the “Browse for more” button to locate its .exe file. This will add the program to your editor list. If you want to set it as your default, click the Make Default button, as shown in Figure 3-8, before you close the dialog box with the OK button.

Figure 3-8. Make sure that you use the OK button to save your changes.

53

54

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

For any file extension with more than one editor listed, Expression Web will give you the option to open the page with all of the programs on the list, as shown in Figure 3-9.

Figure 3-9. Right-clicking Open With shows all editors associated with the file extension.

Page Editor Options Although I know all this configuration information might seem boring, there are bits that will make a difference in how your pages render. Here, you will be looking at the Page Editor Options. Some of the tabs will be quickly explained but have no real changes to be made; however, there are a few where you should pay attention to the settings. The ones you will be focusing on are General, CSS, and Font Families. I will touch on a few options under the Authoring, IntelliSense, and Code Formatting tabs as well. The other tabs will be grouped together. The General Tab We will quickly go through the defaults that can be selected under the General tab, which are numbered in Figure 3-10, and where appropriate I will explain the effects of the choices you might make.

Figure 3-10. Page Editor Options is where you set defaults for all of your Expression Web sites.

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

The options on the General tab have been given numbers to make cross-referencing them with their explanations easier: 1. Automatically enclose form fields within a form: Leave this checked. 2. Assign unique IDs to new tables: If you use only data tables, checking this would be worthwhile, but if you use layout tables, you do not need and probably don’t want an ID automatically assigned. 3. Make ID unique on paste: Since there can be only one ID per page, this is probably a good item to leave checked, but you might prefer to assign IDs yourself. 4. Use and when using bold and italic toolbar buttons: You should leave this one checked, because and have semantic meaning for screen reader users. They might also help search engines determine what to pay attention to on your page as long as you do not overuse them. 5. Automatically switch keyboard to match language of surrounding text: This is almost the opposite of the Site Settings Language tab you looked at in Chapter 1. If you use multiple languages on your site and are knowledgeable about the keyboard layout native to that language or country, then you might want to check this box. For all others, I recommend leaving it unchecked. 6. Prompt for accessibility properties when inserting images: This is new to Expression Web and something I am glad to see, since alt attributes are not only required for accessibility but also for all valid versions of XHTML and HTML 4.01. Do not remove the check from this check box, or it will haunt you. 7. Spelling Options: Clicking this button opens a dialog box with spelling options. I do not recommend selecting the check box to hide spelling errors, since errors that should have been caught by a spell-checker might cause your site to lose credibility. 8. Show Paste Options buttons: This option will allow you to decide whether to bring formatting when you are pasting text. 9. Word wrap: This is for the Code view, since text wraps automatically in Design view under HTML specifications. This setting is a personal preference; there is no right or wrong choice. 10. Auto indent: This option is also applied to the Code view and is another personal preference—one that will make it easier for you to move from one section of the code to another. I recommend leaving it checked. 11. Selection margin: This adds a margin to the left side of your code to make it easier to work with blocks of text in Code view. 12. Highlight invalid HTML: I recommend keeping this checked, since it makes finding errors much easier. This is particularly useful when you are working on a web page that is not valid and moving it to current standards. 13. Highlight incompatible HTML: This will alert you to code that is not correct for your doctype, such as elements that improperly closed. I can think of no reason to disable this option.

55

56

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

The AutoThumbnail Tab The next tab is AutoThumbnail, which allows you to make small thumbnails of your images and link them to the larger version in one operation. I recommend you make your thumbnail images in a dedicated graphics editor where you have full control of your optimization settings, but if you are just putting together a prototype, the thumbnail capabilities of Expression Web are adequate. The Picture Tab The defaults here affect only images you paste into your pages by copying and pasting them into an open page or by importing a Word or other file with images embedded in it. They do not affect images you import into your local website. As with the AutoThumbnail tab, converting pictures from one format to another is best done in a full-fledged image editor. You do have limited control over the quality of your converted image from the Picture File Types dialog box using the File Type Settings, but this method of editing images is not the best one to use. The Ruler and Grid Tab There might be cases when you want to align elements on a page using a line or grid. The settings on this tab allow you to display grid lines using the spacing you choose. Remember that web pages are measured in pixels (px), which are the units of measurement for a display, not inches, centimeters, or points, which are units of measurement for print media and should not be used on the Web. The Default Fonts Tab The top half of the Default Fonts tab, shown in Figure 3-11, duplicates the Language tab of the Site Settings menu. You should set both of these to match one another. Expression Web follows the W3C recommendation of using UTF-8 as the default. Unfortunately, Expression Web adds hidden characters called Byte Order Marks (BOMs) to the top of each page, which can cause problems with some web servers and all PHP pages. If you are using English or another western European language, I recommend selecting US/Western European (ISO), as shown in Figure 3-12, to prevent the BOM characters from being added to the page. If you are using Cyrillic, Arabic, Hebrew, or an Asian language, use the language-specific encoding, UTF-8, or UTF-16. The bottom half of the Default Fonts tab will allow you to set the default fonts that are used inside Expression Web.

■Note Changing the default from Times New Roman for Design view will not change the browser default when the page is viewed. Changes made here will affect pages only when viewed in Design view. I recommend leaving the defaults as they are set, since Times New Roman is the default for Internet Explorer and Firefox. To change the fonts used by the browser (and in Design view), you will need to use CSS.

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

Figure 3-11. The character set tells the browser what set of alphanumeric and symbol characters will be used on the page.

Figure 3-12. In most cases, US/Western European (ISO) will be your best choice for the default Web Expression character set. If you want to change the font displayed in Design view, use a font family in your CSS body definition. That way, what you see in Design view will match what the visitor sees on the Web. The Code view settings, on the other hand, will not affect how your code is displayed on the Web, and you should set those for your own comfort. Users with high-resolution screens might find 9-point text too small for comfort, while others might prefer a smaller font so they can see more at a time. The Code Formatting Tab There are a lot of settings you can change on the Code Formatting tab. The defaults will work well for most people, but if you have a code display preference, you can configure Expression

57

58

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

Web to match it. It is possible to get very granular in your display settings, down to specifying which attributes will contain a line break or a specific number of spaces and where those will be located. Unless you have a particularly strong preference, I suggest leaving the defaults. The Color Coding Tab Using color to distinguish elements, attributes, values, selectors, properties, and scripts will make it easier to spot problems caused by improper editing as well as missing elements. For most people, the defaults do not need to be changed, but if you prefer a specific color scheme, this is where you change it. The IntelliSense Tab Also referred to by some as code completion, IntelliSense is one of the most useful features Expression Web has when you are working in Code view. I recommend checking the boxes for all options, as shown in Figure 3-13, since selecting code as you type and putting in the proper quotes will prevent code errors from creeping in.

Figure 3-13. IntelliSense can help you prevent typos. The only drawback to IntelliSense is that it does not support scripting languages other than ASP.NET 2.0. There might be add-ons available in the future to add support for other scripting languages.

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

The CSS Tab It is not possible to discuss the CSS tab, shown in Figure 3-14, without discussing CSS. In this section, there are several exercises and sidebars to help you make sense of the options you will be choosing here. Consider this an appetizer before you start using the CSS-related task panes in creating your pages.

Figure 3-14. A few changes to the CSS defaults will make your work flow better.

CSS BASICS Recall that CSS stands for Cascading Style Sheets; these stylesheets contain a series of styles and definitions (we will be working with CSS more extensively in Chapter 5). Each style consists of three components: • Selector: This is typically an HTML element, a class, or an ID. • Property: This is the presentation item you are trying to define. • Value: This is the property definition. In the following examples, you will see one of each of the types of selections and an example of its use. The general syntax of a CSS style follows: selector {property1: value;}

Continues

59

60

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

You can have more than one property in a style: selector { property1: value; property2: value; }

Selectors There are three types of selectors: • HTML element: The style definition will affect all instances of the specified element on pages that use this style; for example, to set the color of all elements, you would use this definition: h3 {color: #666666;} • Class: This style will apply to any element that has the class applied and might be used more than once on a page: .feature {font-style: italic;} • ID: Styles assigned with an ID can be used only once per page, so you should reserve them for structural elements: #special { background-color: #efefef; border: medium #666666 solid; padding: .5em 1em; margin: 1em 6em; } The following image shows what the browser would display with a with id="special", an defined as in the previous code snippet, and the feature class applied to the paragraph element.

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

A is a block-level element with no semantic meaning that is normally used for sections. Think “page divisions.” Though not used in this example, a is an inline element used as a hook to apply a style or to provide for a tooltip or script ID. In all, six property elements are used in this sidebar’s example: • color • background-color • border • font-style • margin • padding

CSS Shorthand Expression Web gives you the option to write each CSS property individually or to use what is called CSS shorthand, where multiple properties and values are written on one line. The border style in this sidebar uses shorthand. There are three separate values for border: size, type, and color. Without any sort of shorthand, that one line of CSS would be written as follows: border-top-style: solid; border-top-width: medium; border-top-color: #666666 ; border-right-style: solid; border-right-width: medium; border-right-color: #666666 ; border-bottom-style: solid; border-bottom-width: medium; border-bottom-color: #666666 ; border-left-style: solid; border-left-width: medium; border-left-color: #666666 ; While some people prefer the expanded format while learning CSS, using shorthand will make your stylesheet more compact, faster-loading, and, in most cases, easier to read and edit. We will go into the specifics of properties and values later in the book when you are working with the CSS task panes.

In the CSS tab, you will leave the Auto Style Application setting selected, since this is the best choice for most users. This setting tells Expression Web to look at what you are doing and apply any matching style linked to your page. If there are no matching styles, then Expression Web will create a new style to match your font, border, background, layout, and so forth.

61

62

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

By default, the majority of the CSS that Expression Web writes will be written as styles in the section of the page. However, there are two types of styles that are written inline, as shown in Figure 3-14. My recommendation is that you change those two settings. All of the options should be set to “CSS (classes)” with the exception of the “Page properties on the tag” option, which does not offer the option to use classes since it is an HTML element. Otherwise, you lose many of the benefits of stylesheets, that is, the ability to make one change that affects all the pages on your site. The two settings Microsoft has chosen to make inline follow: • The first inline setting is the “Page properties on the tag” option, where your options are the “CSS (inline styles)” option and the “CSS (rules)” option. Since a tag will be used only once on the page, you would not need a class. In some circumstances, you might want to use an ID to select a different default for certain pages in your site when an ID would be appropriate to do that, but for your normal defaults, redefining the element is the best choice. • The other option that is set to inline styles is the “Sizing, positioning, and floating” option. Leave the defaults, the “CSS (inline styles)” setting, until you are directed to change them for the exercises in this chapter.

TYPES OF STYLES Styles can be written and applied using one of three methods: • Inline styles: These styles apply only at the location where the style is written and are similar to the old HTML 3.2 element:

• Style block: The style is written in the section of the page and will apply to every selector on the page:

The style is applied to every

element on the page by default. • External stylesheet: Styles are in a separate document with the .css extension attached to the page either by using a relative link

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

or by importing it into the page:

Using external stylesheets will keep the style definitions the same throughout your site. section styles can be used to change the appearance on just one page. Inline styles will allow you to override both the section style and any style in an external stylesheet for one instance on your page. Since it is more difficult to locate and change inline styles on your pages, they should be used sparingly.

Creating Styles Although you will be creating styles in this book using the new styles method, you can also create styles by using the buttons on the Format toolbar. When you use the Format toolbar to create a style, Expression Web will automatically name the styles with class names of .style1, .style2, .style3, and so forth. The check box you see near the bottom of the CSS tab lets you choose whether to limit the automatic application of styles to those created by Expression Web or to include those you create or rename. My recommendation is to leave this box checked. To avoid creating separate classes for each image on your page, leave the check in the “Use width and height attributes for images instead of CSS” box. This will also help your page load properly. Have you have ever visited a web page where the page rearranged itself after all the images loaded? It did that because the height and width of the image were not in the HTML, and the browser did not know how much space to reserve when laying out the page. In that case, the browser has to reflow the page, because the image and stylesheet usually load after the HTML. Exercise 3-1 shows the effect of changing the CSS Tab Styles setting, Exercise 3-2 shows the effect of changing the Body setting to Rule, and Exercise 3-3 shows how to change styles for the positioning of your website.

Exercise 3-1. Seeing the Effects of Changing the CSS Tab Styles Setting In this exercise, you will compare the effects of the default settings of Expression Web with the recommended changes to the effects of the CSS styles that are written as you create them in Expression Web. 1. Download the exercise.txt file from http://foundationsofexpressionweb.com/exercises/ chapter3/ch3example1.txt or the chapter3.zip file containing all the Chapter 3 exercise files, and save a copy to your project web. Or type the following lines into Code view and save them as exercise.html:

63

64

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

CSS Test

CSS Test Page

Menu Section

  • Link 1
  • Link 2
  • Link 3
  • Link 4


Content

We will be using this basic page for many of our exercises so you should archive a copy of this file to use for your exercises in exactly this format.

If you wish you can add more paragraphs to the content section and bring in some images from your computer. While I could provide you using images (there are some images the zip file) and more content but using images and content of your choice will make the exercises more realistic.

Next Bit

Some more paragraphs and maybe even breaking up content into more lists will appear in this section.



Footer, copyright and stuff

■Note You can insert an image of your choice using File ➤ Insert ➤ Picture ➤ From File. If you downloaded this file from the website, you might use one of the images in the zip file.

You will be using this file in multiple exercises, so make sure you make a new copy before you begin each of the exercises that follow.

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

The exercise.html page consists of four sections, or s, with content in each . Before you continue with the exercises, save a copy of your exercise.txt or exercise.html file as exercise1a.html. Please use Split view for all the exercises in this book unless directed to do otherwise.

The Effects of Using Inline Body Styles The best way to understand why changing CSS defaults will help you make your website easier to maintain is to first see what the defaults do by creating styles using those defaults. 1. Right-click anywhere in Design view and select Page Properties, or select File ➤ Properties to launch the Page Properties dialog box. 2. Set the page background color and text color from the drop-down menu on the Formatting tab (see Figure 3-15). Make sure that you actually select a body color and a text color. Contrary to what many people believe, not all browsers use white as their default background color. Some versions of Netscape, for instance, use a light gray. You might optionally add a background image. 3. Click the OK button.

Figure 3-15. To quickly set basic page-level formatting from the Formatting tab, select your background and text colors. 4. Now look at the element in the code section of Split view.

■Note Select the element from the Quick Link bar. The element will be highlighted in Code view.

65

66

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

You should see an inline style that looks like this:

5. Next, return to the Page Properties dialog box, and choose “Hyperlink state colors.” You should see something like the following code written by Expression Web:

These are the styles written in the section of the document and will apply to all links and their states, which are called pseudo-classes. Preview your exercise.html page in the browser of your choice, and move your mouse over the links to see the rollover effects caused by the hover pseudo-class. 6. Select the element again, and from the Format bar, click the Borders button to add a border to your web page, as shown in Figure 3-16.

Figure 3-16. Select Outside Borders from the Format bar’s Borders drop-down. You will see that you have created a style instead of adding it to the inline style in the element: .style1 { border-style: solid; border-width: 1px; }



CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

PSEUDO-CLASSES Pseudo-classes apply a style based on an element’s state such as link, visited, hover, and active. These are what gives your links a different color when you have visited the page to which the link leads. The pseudo-class of hover provides the rollover effect when you mouse over the link when you change the color, background color, or image; add or remove an underline; or add other touches. For your CSS-based rollovers to work, your pseudo-classes must be in the order listed; some people use the “LoVe HAte” mnemonic as a memory aid: • link • visited • hover • active

Exercise 3-2. Seeing the Effect of Changing Body to Rule Expression Web uses CSS (rules) when referring to using the HTML element as your selector. In this exercise, you’ll see how styles are written when the element is used as the selector in the CSS tab. 1. Begin by saving another copy of exercise.txt as exercise1b.html. 2. With the new page open in Expression Web, go to Tools ➤ Page Editor Options ➤ CSS tab, and change the body’s setting to the “CSS (rules)” option, as shown in Figure 3-17.

Figure 3-17. There should be no “CSS (inline)” in your CSS tab settings now. 3. Next, add the same page properties and border to the element.

■Note When applying the border property to the element, there is a bug. What you see is a body style with the background color and text color but a separate style1 for the border, which was applied to a instead of to the element. In the first exercise, the style was correctly created and applied to the element, but in the second exercise no style should have been created, and the border property with its associated values should have been added to the element.

67

68

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

4. Compare the code between the exercise1a.html and exercise1b.html. What you should see follows: body { color: #333333; background-color: #FFFFFF; border-style: solid; border-width: 1px; } The code you should have seen could easily be transferred to an external stylesheet to use on all subsequent pages to make maintaining your site easier. This is the code that would be created if you used one of the CSS task panes or the Styles dialog box to create your CSS instead of using a combination of the Page Properties settings and the Format toolbar. While the Page Properties settings are useful for basic, quick formatting of your page styles, it is best not to use the Format toolbar on the element.

Exercise 3-3. Changing Styles for Positioning Next, you will see the effect of making the recommended change of “Sizing, positioning, and floating” from “CSS (inline)” to “CSS (classes)” for a single page, while leaving the default of the “CSS(inline)” setting. Perform the following steps: 1. Select h1 in Design view. Then, from the Quick Tag bar, select the element that precedes it in the list, which will show the boundaries of the element in the design windows. 2. Drag the bottom of the highlighted area (using the bottom-center round bullet shown Figure 3-18) so that the is approximately 75px high.

Figure 3-18. Make sure that you drag the round bullet to change the height or width of a highlighted section. 3. Select the h1 again, and apply a font family and color from the Format toolbar. You might also change the text size if you want; for now, use only relative sizes such as xx-large or small. 4. Right-click or use the drop-down arrow on h1.style1 in the Quick Tag bar. 5. In this dialog box, select Tag Properties to launch the Paragraph dialog box shown in Figure 3-19, and add a left-side indentation.

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

Figure 3-19. By default, the indentation is 0px. You can type in the number of pixels you want to indent the h1 element. 6. Go to the next , click somewhere inside it, and choose the element from the Quick Tag bar again. 7. Right-click the arrow to launch the drop-down box for the , select Positioning and then “position: absolute” (see Figure 3-20).

Figure 3-20. Choose the “position: absolute” option 8. Next, in Design view, drag the right side of the positioning box until the width is 170px wide using the rightside dot.

69

70

CHAPTER 3 ■ STARTING OFF RIGHT: CONFIGURING EXPRESSION WEB

■Note It is very easy to set both a height and a width when you are dragging an element to size it. If you create a height or width you do not want specified, simply delete it in Code view.

9. Move to the main content , and repeat steps 6 to 8 to apply absolute positioning to your main content . This time, drag the right side to 190px, or whatever looks to you to be sufficient space for the leftside menu. 10. For now, move the that contains your footer inside the container , and change the font size to a smaller font size using the Format toolbar. This is starting to look like a real page, isn’t it? I do not suggest you use this layout as it is written by Expression Web, since the way you created it does not give you the most robust layout (and you will be creating robust layouts using CSS later in this book). As you can see, using inline styles would make it hard to transfer this page to an external stylesheet, which is the point of this exercise. 11. Save this page as exercise2a.html. 12. Now, select Tools ➤ Page Editor Options ➤ CSS tab, and change all of the remaining properties to “CSS (classes)” (you should have already changed the body styles to “CSS (rules)”). Your CSS tab options should now look like Figure 3-21.

Figure 3-21. Your CSS tab style settings should look be all “CSS (classes)” or “CSS (rules)” after this exercise. 13. Now that you have changed the sizing, positioning, and floating from inline styles to classes, repeat this exercise with a fresh copy of your exercise.html file saved as exercise2b.html, and compare the resulting code to exercise2a.html. When you are creating multiple web pages with the same layout, having all the presentation elements in one • External: This is where your style definitions are contained in a separate CSS page that is linked to one or more pages on your website. p {color: red;}

111

112

CHAPTER 5 ■ ESSENTIAL CSS: WHAT YOU NEED TO KNOW

Inline This type of style is closest to the older tag method of styling since it applies only to the section of the page enclosed by the style declaration. To create a gray heading 2 that is centered on the page using an inline style, you use code that looks like this:

Centered Gray Heading

The will display like Figure 5-1.

Figure 5-1. Inline style example This works well in every browser that has even a modicum of stylesheet support, but it has the same maintenance drawbacks of using tags.

Document Level If you want all elements to be centered and gray on one page only, the style code can go in a When you use Expression Web to create your styles with the configuration options recommended in Chapter 3, you will get a code block that looks like the one shown in Figure 5-1. The type="text/css" part tells the browser that the code inside the There are two reasons you might want to use the insert method over the link method: • To hide styles from older browsers that might have a problem with certain CSS 2 elements. The primary browser in this case is Netscape 4.x, which has rather buggy HTML support. Embedding is not often used for this purpose because Netscape Navigator 4.x is rarely used anymore. • To change the order of the cascade so that the external stylesheet is treated as if it were a document-level stylesheet.

C for Cascade So far I have addressed only the style portion of CSS, but the first letter in CSS stands for cascading, or how the styles flow down from one level of the document like the cascade of a waterfall. Understanding the cascade, a.k.a. how style conflicts are resolved, is an important part of using styles. As stated, there are three types of styles: inline, document level, and external. The cascade is important because you can have more than one style that applies to an individual element. The style definition closest to the code that uses the style is the style that will be applied in terms of both specificity and the location of the style definition. This means you can define a default for your website in the external stylesheet, change that default in the section for just one page, or change it in the element itself to force a difference in just one instance. The best way to understand how the cascade works it to use styles; for that reason, it is important that you do Exercise 5-1.

■Note Each of the figures in Exercise 5-1 use the same Internet Explorer 7 window size.

Exercise 5-1. Understanding the Cascade In this exercise, you’ll get some practice using styles so you can understand how the cascade part of styles works. 1. Copy the following code to a new page, and save it as external.css in your local website: body { background-color: #FFFFFF; color: #000000; font-family: Tahoma, Helvetica, Arial, sans-serif; }

113

114

CHAPTER 5 ■ ESSENTIAL CSS: WHAT YOU NEED TO KNOW

h2 { color: gray; text-align: center; } p { font-size: small; } 2. In the same folder as you saved the external.css file, copy the following code to a new HTML page, and save it as cascade.html:



Cascade Example

Cascade Test Page Document Style Applied

Here is what the page would look like with just the external stylesheet applied. This is a basic paragraph of text that I added so you could see what the default style would look like. In order to have enough text to view I'm adding a block of filler text below. As more text is added you will see what it looks like with different bits of style code added.

This copy is used for placement only. It is not meant to be read. Designers use this to show clients how copy would look if it was inserted. This copy is used for placement only. It is not meant to be read. Designers use this to show clients how copy would look if it was inserted. This copy is used for placement only. It is not meant to be read. Designers use this to show clients how copy would look if it was inserted.

This copy is used for placement only. It is not meant to be read. Designers use this to show clients how copy would look if it was inserted. This copy is used for placement only. It is not meant to be read. Designers use this to show clients how copy would look if it was inserted.



CHAPTER 5 ■ ESSENTIAL CSS: WHAT YOU NEED TO KNOW

3. When viewed in a browser, the page should look like Figure 5-2.

Figure 5-2. Browser display when an external stylesheet is linked to this web page The line of code that attaches the external stylesheet is as follows:

4. Next, add the following

115

116

CHAPTER 5 ■ ESSENTIAL CSS: WHAT YOU NEED TO KNOW

5. The page will now look like Figure 5-3; notice how the background color of the paragraph text is now gray and larger than in the original example? The paragraph text size changed from small in the external stylesheet to medium in the section’s 9. Now in Design view, your paragraphs with the gray background should be white again. Click anywhere in the last paragraphs, and from the Styles drop-down list, use the bottom option, Apply Styles, which will open the Apply Styles task pane. Double-click the entry shown for the shaded class, as shown in Figure 5-5.

117

118

CHAPTER 5 ■ ESSENTIAL CSS: WHAT YOU NEED TO KNOW

Figure 5-5. Double-clicking the style in the Apply Styles task pane will apply the style. 10. Your page should now look like Figure 5-6.

Figure 5-6. You can now see each of the styles applied. In Figure 5-6, you see the external style for paragraphs applied to the first paragraph. The second paragraph has an inline style. You should use inline styles sparingly. The third paragraph has a class from the section applied. Don’t forget to preview the page in your browser.

CHAPTER 5 ■ ESSENTIAL CSS: WHAT YOU NEED TO KNOW

@import and Older Browsers When an external stylesheet is embedded using @import in the page instead of being linked, the effect is the same as if the style itself was written in the

■Note The @import statement is sometimes surrounded by HTML comment tags, such as inside this is a comment that will not be displayed in the web browser -- >, to prevent older browsers that do not understand @import from showing in the code. In most cases, this is no longer necessary.

By using conditional comments targeted toward Internet Explorer 6 and below, you can remove the translucent background and replace it with a solid color that harmonizes with the page background image. The following code would go after the closing

Remember that one of the primary benefits of using CSS is that you can provide an enhanced view to those with modern browsers and still provide a usable and attractive site to those who do not have the latest and greatest browser.

Building a Page Layout In this chapter you’ve been building a page layout as you worked through the CSS options in Expression Web. There are two types of page layouts: • A fluid layout will shrink and grow depending on the width of the visitor’s browser. Typically a fluid layout will have two or more columns. Frequently at least one of the columns will have a fixed width, while the other will expand or contract with the width of the browser. • A fixed-width layout has a specified width and is usually centered in the web browser. The structural.html web page is a fluid page that, because of the fixed background, would look better as a fixed-width page. If you have been previewing your web pages in a browser that is 1,024 pixels or wider, you may have noticed that the line length on the text is longer than most people prefer to read even with a second column. The content overflows the

203

204

CHAPTER 7 ■ CSS POSITIONING USING EXPRESSION WEB STYLE TOOLS

background image in a way that can be distracting, especially in those browsers that fully support the translucent background. There is more than one way to restrict the width of our page. The simplest method is to put a width on the element and center it in the page over the background image; you’ll do that in Exercise 7-4.

Exercise 7-4. Creating a Centered, Fixed-Width Layout With your menu.html web page open, right-click the body style in the Modify Styles task pane, and select Modify Style. 1. From the Position category, set the width to 740px, which is the width of the image. You’re using 740px because it will not cause a horizontal scroll in any web browser viewed at 800×600.

■Note 800×600 is the outside dimension of the web browser when viewed full screen on a computer monitor that has a screen resolution of 800×600. To get the amount of space that is available to display your web page, you must subtract a minimum of 20px for the horizontal scroll bar (Internet Explorer always reserves space for the horizontal scroll bar whether it is needed or not) and the side chrome of the browser. Although in most cases 760px will not cause a horizontal scroll, you might not want the layout right against the sides of the browser.

2. In the Box category, use 0 for the top and bottom margins and auto for the left and right margins. You do not want to add padding to the body because that would cause your and menu to have space between the items. Set the padding to 0 to make sure that all browsers do not apply any default padding. You will be applying a border to just the left and right sides of the element, as shown in Figure 7-38.

Figure 7-38. You can see the faint border that defines not only the edge of the text area but also the edge of the background image.

CHAPTER 7 ■ CSS POSITIONING USING EXPRESSION WEB STYLE TOOLS

3. At this point you should also add a small amount of padding to the right side of the #maincontent, as shown in Figure 7-39.

Figure 7-39. You built padding into the left side when you created the main content left margin. Adding padding here moves the text away from the right border. 4. Add padding to the right and left side of #footer, as shown in Figure 7-40.

Figure 7-40. Text always looks better when there is some space between the text and the border. Don’t forget to preview your finished web page in a variety of web browsers. You might notice that there are differences in how the masthead appears. Some of these differences are because of the different way that border inset and border outset are rendered. There is nothing you can do to change how that style border displays, but you can remove the extra space at the top of Firefox by adding margin-top: 0 to the h1 definition.

205

206

CHAPTER 7 ■ CSS POSITIONING USING EXPRESSION WEB STYLE TOOLS

Summary Over the course of your CSS exercises you have taken a plain XHTML outline and turned it into an attractive web page using modern CSS presentation. Using older-style table-based layouts with elements would have increased the size of your page. In the following chapters, as you finalize your web page layout, going from one web page to a full website, you will be taking the CSS you created and moving it from the section of your page to an external stylesheet to keep your web pages consistent within your site and take advantage of browser caching to speed up page load.

CHAPTER

8

Branding Your Website T

here are millions of websites out there, yet it is easy to tell as you follow a link when you have left the website you were on. This is because each site has a distinct look and feel. Occasionally you might run into two (or more sites) that look alike where you can tell that those sites are using the same theme or template—usually that of a website generator, blog application, or a standard template included with a web-editing program such as Expression Web, Dreamweaver, or FrontPage. In this chapter, you will make your website unique. You will be working on the look and feel of your website. This is primarily determined by your choice of colors and images. Each page and section of your site should have the same look and feel. These are the elements common to every page on your site. The visitors feel at home when they can tell what to expect from your website. Sites that are radically different from the norm tend to be ineffective. In Western culture, that means people expect the top section—or, to borrow a term from print, the masthead—to identify the site. Site navigation or menus should be clear, easy to locate, and intuitive to use. The main content section should occupy the majority of the page. Side columns usually have menus, teasers, related information, and/or advertising. Legal notices such as copyright, privacy policies, contact information, and so on, are usually in smaller print at the bottom of the page. These are the sorts of conventions that make your visitor comfortable. The term mystery-meat navigation was coined to refer to sites that are difficult to navigate or have menus that are hard for a visitor to recognize as a menu. Your site menu is an important part of your site’s identity and function. Although your site may use the same basic layout as thousands of other sites on the Web, it does not mean that your site has to look the same as every other site on the Internet. Your choices in color and images will give your site a unique look that will help brand it in the eyes of your visitors.

Choosing a Color Scheme When most people start out in web design, one of the most common sticking points is deciding the colors for the website, followed by what images to use. In the case of a business site, frequently a company logo or official colors will provide a starting point. However, if it is a new venture or a personal site, you might not have a logo or any other graphics to get you started. One place to start is to look at the subject matter that will be the content for your website. In many cases, the content will suggest a particular color. For example, a hobby site about poodles will want to use colors that complement black, silver, apricot, and white—colors that will 207

208

CHAPTER 8 ■ BRANDING YOUR WEBSITE

show off the poodles on your site. A site for coastal cottage rentals might suggest sea and sand colors that people associate with a sunny beach, even if the cottages are not right on the beach. If you have photographs that relate to the subject of your website, choose the photographs you like the best, and then pull your color scheme from inside those pictures using the eyedropper from the color picker. If the subject matter of your site doesn’t suggest a color scheme, another method is to take your favorite color and then use a color wheel to select your colors. There are three basic types of color schemes: complementary, analogous, and monochromatic colors. Choose one type to make up the color scheme for your website. Additional resources are available on this book’s companion website at http://foundationsofexpressionweb.com (including links to more color resources).

Complementary Color Schemes A complementary color scheme is one where the colors are taken from opposite sides of the color wheel. An example of a popular complementary color scheme is blue/orange. The orange really pops against a dark shade of blue. Use care with complementary color schemes since the text can appear to vibrate if complementary colors are stacked on top of each other. That is why you should mix black and white liberally in with complementary color schemes. A variant called split complementary, or triad, where the color wheel is divided into thirds, is often used, and colors equal distance apart on the wheel are used. Like a two-color complementary scheme, a triad scheme will pop but does not tend to cause as much movement to appear on the screen, which frequently makes it a better choice.

Analogous Color Schemes Colors that are adjacent to each other on the color wheel make up an analogous color scheme. These usually go from one primary color to the next or from one secondary color to the next on the color wheel. A site that uses blue and green as the primary colors would be using an analogous color scheme.

Monochromatic Color Schemes Monochromatic color schemes use one color in various shades, which can be very effective depending on the subject matter of the website. The web page you created in Chapters 6 and 7 uses a monochromatic color scheme.

Choosing Images for Your Site In its early days, the Web was text only, but it didn’t stay that way for long. Mosaic, one of the earliest web browsers, introduced the element back in 1993. Although at that time most websites were text, images soon became the norm on sites. Like your color scheme, the images you use on your site should relate to your site’s content and goals. To use images effectively, you will need to edit and optimize them. Always start with the highest-quality image. Although Expression Web has some very basic image-editing tools, you should invest in a graphics editor, especially if you want to create original images or edit photographs. Some of

CHAPTER 8 ■ BRANDING YOUR WEBSITE

these graphics programs will be listed in the resources section on this book’s companion website at http://foundationsofexpressionweb.com.

Graphics It is best to use original graphics created just for your site. This prevents several problems: • Clip art can give your site a cookie-cutter or amateur look when visitors recognize the graphic from other sites or as included with Microsoft Office. • Under current law, the person who creates any graphic, text, or code owns the copyright even if they have not registered it with the U.S. Copyright Office. Your graphics do not have to be complex, and simple text effects are frequently one of the best ways of adding graphics to your site.

Photos Like with graphics, original images are best: • Take your pictures with a high-quality digital camera, or scan them from a high-quality photo print. • Then optimize them for the Web. • Few will wait ten or even two minutes for your photo to download. If you need a higher resolution or larger size for distribution, use a thumbnail with a link and file size to the larger image.

Stock Photos Sometimes you don’t have or can’t get the photo you need. This is when you should turn to stock photos where you can obtain royalty-free images for use on your site. There are photo disks available for purchase, and many websites sell you a license to use images for as little as $1 an image. See the resources section on this book’s companion website for a short list.

Image Formats There are only three image formats you should use on the Web: • GIF (Graphics Interchange Format): Created by CompuServe and limited to 256 colors, this format is ideal for line art and images with a limited color palette. It is not good for complex images with gradients or shading. Until the advent of PNG files, this was the only format for the Web that supported transparency. Using what is called index transparency, only one color can be transparent in a GIF. • JPG or JPEG (Joint Photographic Experts): Created primarily for photographs. It works well for images with gradients or thousands of colors and for complex images.

209

210

CHAPTER 8 ■ BRANDING YOUR WEBSITE

• PNG (Portable Network Graphics): Originally created as an alternative to the proprietary GIF format and offers major improvements. The compression format is lossless. There is support for both index and alpha transparency. Alpha transparency includes translucence and not just single color transparency. Like JPG files, thousands and even millions of colors are supported. All these formats compress images to make the file size smaller and download faster. The first two types, GIF and JPG, are lossy, which means pixels are thrown out. This can cause the image to degrade. In GIFs, colors are simplified and may look flat. With JPG, you lose detail as some of the subtler shading is lost, and if the compression level is too high, artifacts, areas where an image may appear blocky or blotchy because of image overcompression, may be visible in the image.

Adding Images to Your Web Pages The first thing you need to know is that you can count on a web browser to display only those images that are in GIF, JPG, or PNG format. These are the only three formats that all modern web browsers support. Older web browsers (Netscape 4 and Internet Explorer 3 and below) support only GIF and JPG images. As you saw in Chapter 7, PNG support in Internet Explorer 6 and below does not support translucent effects that rely on alpha transparency. These older browsers support only the more limited single-color index transparency. Every image on your web page requires four attributes: • Location of the image: src="images/book.jpg" • Height of the image: height="239" • Width of the image: width="181" • Alternative text: alt="Foundations of Expression Web"

■Note Before you insert an image into a web page in Expression Web, save the web page first to make sure that the correct path is used.

If you do not supply a height and width on your image, your page will appear to take longer to display since some browsers will not start displaying the page until after the images finish downloading. Other browsers will continue to load the page and then shift the content after the images download. Neither option is good for your visitor. In Expression Web, you can insert a picture by selecting Insert ➤ Picture ➤ From File (Figure 8-1), which will automatically insert the height and width of your image.

CHAPTER 8 ■ BRANDING YOUR WEBSITE

Figure 8-1. To browse to your image, use the Insert menu to launch the Picture dialog box. Then browse to the folder where your image is located to insert it on the page. Alternatively, you can locate the image in your folder list and drag it to the location you want your image to appear on your web page. Either way, Expression Web will add the image height and width when the image is inserted in your web page. Whether you select your image by using the Insert ➤ Picture method or by dragging it from your folder list, you will be promoted by the Accessibility Properties dialog box to supply alternative text for the image, as shown in Figure 8-2.

Figure 8-2. Alternative text is required to validate your web page. Do not ignore this box by using the Cancel button. If your image conveys meaningful information or is anything other than purely decorative, make sure you provide a short description of what the image is meant to convey. This is particularly important when it comes to images used as links because visitors will not know where the link goes if there is no alternative text. Not only is alternative text required for your web page to validate, but if your image fails to load for any reason, the visitor will be left with a red X and no clue what is missing. Without this alt text, those using screen readers will know there is an image but will not know what the image shows. If your image is purely decorative, it may not belong in the HTML at all. You should add decorative images to your page via your stylesheet as a background to a or other element.

211

212

CHAPTER 8 ■ BRANDING YOUR WEBSITE

■Tip

alt information should be short and descriptive of either the image or its function. Think about what you would say if you were reading the page to someone over the phone.

In many cases, you will want your image to be on the side of your text and to have your text flow around the image. The way to align your image to the left or right of other content is to use float. Unlike print, you cannot flow text to both sides of an image.

■Caution If the image you intend to use is not in your local website, make sure you import the image into your website before you insert it into your page.

Using floats for aligning images and other elements is a little different from using floats for laying out web pages as you did in the preceding chapter. Although float basics are the same, padding and clearing become more important. In Exercise 8-1, you will create a simple masthead using one small image that could be a logo or a product, before you move on to using images in your masthead.

Exercise 8-1. Floating an Image For this exercise, I will be using the cover of this book as the image; you can download this image by going to http://foundationofexpressionweb.com/exercises/chapter8. You can also use an image of your choice from your local computer. 1. Import the book image and/or the chapter files into your local exercise website. If you prefer, you can use one of your own images; choose one that is no larger than 300px wide and 300px high (but it can be smaller). If you need to resize your image and do not have a graphics editor, you can use the Auto Thumbnail button on the Pictures toolbar (Figure 8-3) to resize your image or the Crop button to trim it. To launch the Pictures toolbar, select View ➤ Toolbars ➤ Picture.

Figure 8-3. The Pictures toolbar provides simple editing capabilities. 2. Begin with a new blank web page, and add an title and a short unordered list. The code I will be using is as follows: Expression Web
The Basics and Beyond
  • home
  • about


  • CHAPTER 8 ■ BRANDING YOUR WEBSITE

  • exercises
  • links
  • contact
3. With your cursor to the left of the word “Expression” in Design view, insert the image into your web page using Insert ➤ Picture ➤ From File. In Expression Web, you do not see thumbnails of the images for you to visually choose from in the Picture dialog box, as shown in Figure 8-4.

Figure 8-4. Insert ➤ Picture ➤ From File launches the Picture dialog box. 4. To make it easier to remember what formats browsers recognize, use the Web Image Formats filter with the Picture dialog box to insert your images, as shown in Figure 8-5.

Figure 8-5. Show only those images that will display in your visitor’s browser using the Web Image Formats filter. 5. When you insert your image, don’t forget to fill in the alt attribute when you see the prompt, as shown earlier in Figure 8-2. Expression Web will insert the height and width of your image for you. If your image is inserted inside an existing structural element, you should see the bottom of the image lining up with the bottom of the text, as shown in Figure 8-6.

213

214

CHAPTER 8 ■ BRANDING YOUR WEBSITE

Figure 8-6. Image in the normal document flow 6. Now create a new class called floatleft, as shown in Figure 8-7. Although some browsers require a width to properly float an element, do not specify a width in the floatleft class since this class can be used with a variety of different images or other items where the width is specified in the HTML as you specified on the CSS tab of Page Editor Options. This allows you to use floatleft as a generic class, which is more efficient.

Figure 8-7. Creating generic float classes keeps your CSS simple. 7. Apply the class you just created to your image, and then preview the page. The result may not be exactly what you expect, as shown in Figure 8-8.

CHAPTER 8 ■ BRANDING YOUR WEBSITE

Figure 8-8. The floated image may need padding for adjoining elements to display correctly. 8. Make a note of the position of your floated image in relationship to the elements around it. In Figure 8-8, the image precedes the element. Move the floated image inside the element. Does it make a difference if the image is inside an HTML element such as a header or a paragraph? 9. Create a second class called floatright identical to the first class, but with the float property set to right instead of left. 10. See what happens as you move the image around in the source code and change float: right; to float: left;. 11. When you change the location of the image to the right (Figure 8-9), it no longer looks crowded since the text does not reach all the way to the right of the page, but that might not be where you want the image placed on the page.

Figure 8-9. When floated to the right, the image no longer crowds the short text next to it.

215

216

CHAPTER 8 ■ BRANDING YOUR WEBSITE

12. Add text to your page; see the sidebar called “Placeholder Text” if you do not have a block of text available or did not download the sample files. Move the floated-right image to a section of your page where the text is long enough to wrap, and you will see the same crowding effect happen but to a lesser degree, as shown in Figure 8-10. (If you do not have content ready to put in a page to see how your page will look, see the sidebar.)

Figure 8-10. Text will wrap around the floated image as needed. 13. To allow for whitespace between the text and the image, you need to add padding to the opposite side of the float. This means adding padding-right: 1em to the floatleft class and padding-left: 1em to the floatright class, as shown in Figure 8-11.

Figure 8-11. The shaded area (blue when seen in Expression Web’s Design view) represents the padding applied to the floated image.

CHAPTER 8 ■ BRANDING YOUR WEBSITE

Most websites will have at least a few floated images, and creating a couple of generic classes to float your images left or right will cut down on the number of classes you need in your stylesheet. Save the file as masthead.html in preparation for the next exercise.

PLACEHOLDER TEXT You will often be working on your website design before you have the page content, but it can be difficult to tell what your page will look like when there is content. Enter placeholder text, which is traditionally fake Latin text called Lorem Ipsum. This type of text is so common that you can find large blocks of it on the Web that you are free to copy without the explicit permission of the site owners at sites such as http://www.lipsum.com/. Latin is not the only type of placeholder copy available; try some of these generators for something different: • An ever-changing selection of text: http://www.malevole.com/mv/misc/text/ • Firefox/Mozilla browser extension: http://mozmonkey.com/loremipsum/ • Generated from Hitchhiker’s Guide to the Galaxy or the Bible amongst others: http://johno.jsmf.net/knowhow/ngrams/ • Corporate Speak, Press Release Generator: http://www.lurkertech.com/chris/corpspeak.html • Text from public-domain works: http://www.gutenberg.org/wiki/Main_Page Or you can simply create your own. If you are redesigning an existing site, you can reuse the current content while waiting for new content, but in many cases it is better to use something that is clearly not related to the subject of the site to make sure that the content gets updated. More information on placeholder text is available at http://clsc.net/tools/lorem-ipsum.htm.

Establishing Your Look and Feel As I’ve discussed, there are a limited number of basic layouts, and what sets your site apart is the colors and images you choose to create your look and feel. It is generally accepted that you have ten seconds or less to grab your visitor’s attention, or they will leave your page. This does not mean you have to have the latest-and-greatest gee-whiz factors on your site. But it does mean that your site visitor needs to be able to tell instantly that your site has what they want. This means using images that relate to the subject of your site, a color scheme that attracts but does not distract, or other style elements that will allow your visitor to find what they need on your site. When you have selected the primary image for your site, whether it is a logo or other image, use it in the same location on every page of your site. That location is typically in the top section of your page, which is frequently called the masthead. Below your masthead you will have one to three columns of content, which are typically followed by the page footer with

217

218

CHAPTER 8 ■ BRANDING YOUR WEBSITE

legal information such as copyright notices, links to your site’s privacy policy, a site map link, or other useful information. In establishing your site’s look and feel, begin with the basic page-level defaults. Choose your font family and default background and text colors. Many people find it easier to read sans serif fonts on the Web. Since browsers do not always have the same color and spacing defaults, it is best to set them explicitly. Then you can add padding or margins back in as appropriate while creating your site’s look and feel. A good basic page definition to begin with is as follows: body { font-family: Tahoma, Helvetica, Arial, sans-serif; color: #000000; background-color: #FFFFFF; padding: 0px; margin: 0px; }

■Note I will be using this body definition in the exercises for the rest of this chapter.

In most cases, your primary branding will be established by your masthead. Picture your favorite website, and the odds are good that what comes into your mind is the masthead. Figure 8-12 shows a few popular examples. Exercise 8-2 shows how to create your own masthead.

Figure 8-12. Examples of mastheads establishing site branding

CHAPTER 8 ■ BRANDING YOUR WEBSITE

Exercise 8-2. Creating a Masthead In this exercise, you will go through the process of creating the masthead shown in Figure 8-13.

Figure 8-13. Finished masthead 1. Beginning with the book image used in the preceding exercise file, use the floatright class to move the image to the right, and add the body style from earlier in this chapter. Make sure that the image element is before your . 2. Next, wrap the text but not the image in a using the right-click drop-down menu in the Quick Tag bar to select Wrap Tag, and give the new an id of masthead. In Figure 8-14, I applied a black border so that you can see happens when a floated image is bigger than the container that you want to hold the image.

Figure 8-14. Images will overflow their container when floated.

219

220

CHAPTER 8 ■ BRANDING YOUR WEBSITE

3. To keep images inside the masthead , you need to specify a height or use a clearing element. In this case, you want to have the masthead line up with the top of the orange section of the image instead of clearing the image completely. Using a screen ruler gives you a height of 119px. To make the book visually separate from the masthead, add a 1-pixel line to the left of the image using margins or padding. 4. Next, modify the masthead style to have a black background and text the same color as the orange in the book with a text-align attribute of right with the following CSS: #masthead { background-color: #000000; padding: 0; margin: 0 124px 0 0; color: #FDB928; height: 119px; text-align: right; } 5. The HTML for your masthead has the image preceding the masthead to address differences where the padding for the element is calculated from in Firefox, Internet Explorer, Opera, and Safari. To ensure that each of the browsers is using the same starting location, you have to specify a right margin of 124px (two pixels less than the width of the image) in CSS Properties or Modify Style.

■Caution Remember that defaults are not always the same between browsers, but when you explicitly set the margin and padding, the browsers should render your content as you expect.



Expression Web Designer

  • home
  • about
  • exercises
  • links
  • contact


■Note JavaScript null links were used as placeholders, as explained in Chapter 4.

CHAPTER 8 ■ BRANDING YOUR WEBSITE

6. As you can see in Figure 8-15, the site branding is starting to take shape.

Figure 8-15. With the background and text colors set, you have the beginnings of a masthead (as shown in Internet Explorer 7). 7. If you were to preview this page in Firefox at this stage, you would see slight differences in how the masthead appears, primarily because of the default text size differences. In both browsers, adding padding between the heading 1 and the image is necessary. Since both browsers see the right edge of the masthead as starting the same number of pixels from the right edge of the browser window, you can now add padding to your . You also want “The basics and beyond” to be displayed smaller than the first line of text but to line up on the right side. Accomplishing these two goals requires two style definitions: one for the element and one to shrink the size of the second line. The CSS is as follows: #masthead h1 { padding: .5em 1em; margin: 0; font-size: 1.5em; } .tagline { font-size: .75em; } 8. Select the second text in the second line of the , and double-click the .tagline class in the Apply Styles task pane. 9. In Figure 8-16 you can see that you are getting closer to the final site branding but the menu is still displaying as a basic unordered list.

Figure 8-16. Your text is now positioned and sized for the masthead.

221

222

CHAPTER 8 ■ BRANDING YOUR WEBSITE

Creating the Menu In Chapter 4, I recommended using an unordered list as a menu. In this section, you’ll take that unordered list and turn it into a horizontal menu. To begin, you will wrap your list in a with the id of menu with the following style using New Style dialog box: #menu { background: url('images/menu-bg.gif') repeat-x bottom #FDB928; height: 45px; } #menu ul { margin: 0; padding: 0 1em 0 0; text-align: right; } #menu li { display: inline; border-left: 1px solid #000000; } The previous code gives your menu the same orange background as is used in the curved section of the book image. A small slice was also taken out of the bottom of the book to continue horizontal lines in two shades of gray across the bottom of the menu section. This image is very small and repeats horizontally along the bottom of the (download the zip file for Chapter 8 from http://foundationsofexpressionweb.com/exercises/chapter8—the image is in the images folder). The menu now looks like Figure 8-17.

Figure 8-17. The unordered list of links is now a horizontal menu.

Although your menu is now horizontal thanks to the display: inline; property, it is not an attractive menu, with the links crowded up against the border used to visually separate the links and the text high in the orange section. You can use one of two methods to center the links in the menu bar:

CHAPTER 8 ■ BRANDING YOUR WEBSITE

• Add margin or padding, but that would not scale well if the visitor needs to enlarge the text size. • Change the line height to the same as the height. This is the method you will use since it allows the visitor to increase the text size two sizes while still keeping the text inside the menu. Adding padding to the left and right of your links will add the whitespace so badly needed between the links. Finally, for a simple rollover there is a slightly increased contrast on the text and an underline only on hover: #menu a { display: inline; border-left: 1px solid #000000; } #menu a { line-height: 40px; padding: 0 .3em; text-decoration: none; color: #333333; } With the link spacing and mouseover behavior added, the menu now complements the website, and you could stop with Figure 8-18.

Figure 8-18. The basic menu is complete. You could stop here or simply add a 6-pixel left margin to keep the same line as in the lower part of the book. Instead, taking a small slice out of the bottom right of the book image and flipping it in your graphics editor, you can add a matching curve to the menu (the image is called menu-lft.gif). Adding the left rounded corner using the image as a background would be best since it is purely presentation, but you already have a repeating background image used to create the bottom border. As a result, you will add the corner image and float it left inside the menu . Since this image is purely decorative, the alt attribute should be empty. The final HTML that makes up your site masthead section is as follows:

223

224

CHAPTER 8 ■ BRANDING YOUR WEBSITE

Expression Web
The Basics and Beyond

  • home
  • about
  • exercises
  • links
  • contact


This makes up your finished masthead with both corners rounded, as shown in Figure 8-19.

Figure 8-19. A finished site-branding masthead for this book

Finishing the Site Links The next step is to make the links do something. In Chapter 4, you saw how to create a hyperlink to existing pages. You can use the same method to create new pages for each of the links to pages that do not yet exist, as shown in Exercise 8-3.

Exercise 8-3. Creating a Hyperlink to a New Page Begin with either the HTML code used in this chapter or any simple link. 1. Select the element surrounding the about link in the menu shown in Figure 8-20, and select Hyperlink Properties. 2. In the Edit or Add Hyperlink dialog box, select Create New Document from the left column, and then type the filename for your new page, as shown in Figure 8-21. If necessary, you can change the location of the file in your website using the Change button. Use the “Edit the new document later” radio button. In Chapter 9, you will be applying a dynamic web template to the pages you create using this method.

CHAPTER 8 ■ BRANDING YOUR WEBSITE

Figure 8-20. Launch the Hyperlink Properties dialog box.

Figure 8-21. You can quickly populate your website with blank pages to match your site navigation.

225

226

CHAPTER 8 ■ BRANDING YOUR WEBSITE

3. For pages that exist, use the Existing File or Web Page option in the “Link to” category, as shown in Figure 8-22. You do not need to add new pages at this time since they can be created using a dynamic web template in Chapter 9.

Figure 8-22. You can use the same method to add existing pages to your site navigation.

The masthead you created in this section is more complex than you may feel comfortable creating at this stage because of the precision needed in placing the menu. Most of the mastheads you will create will be simpler, consisting of an image and text without complex positioning. When you see a web page and want to learn how it was created, you can open the page in Expression Web and explore how it was done. For example, the masthead used on starttoweb.com consists of an image as the background of the masthead that is sized to prevent the image from being cut off. The masthead used on by-expression.com uses a repeating background image sliced from the right edge of the logo to create the illusion of a graphic that expands and contracts with the width of the page. Before you move on to turning your web page into a template, you need to finish up by adding the two-column layout shown in Figure 8-19. The code for this page is as follows:



Chapter 8



Expression Web Designer
The Basics and Beyond

CHAPTER 8 ■ BRANDING YOUR WEBSITE

  • home
  • about
  • exercises
  • links
  • contact


 

left side column Branding

main content area

You don't need to go as high contrast as this to get your branding across.

Overview

In this exercise we will be creating our website look and feel. Since there is no content to be placed here yet, placeholder, or what is called designer text, will be used after this paragraph.

Created by the Press Release Generator

Thanks to the recent reorganization, the key players are not going to step up to the challenge of competitive killer apps. Having first verified that the drop dead dates give a clear channel towards quality control, a careful examination of the writeoffs reveals that the scenarios provide an indication of the established standard application framework.

Task-oriented disclosures make it happen.

As always, the workgroups empower compliant turnkey systems? Having first verified that the goals enable kick-ass graphics, a careful examination of the best systems in the world reveals that revolutionary RISC technology is not the object-oriented headcount readjustments.

More Generated Content

Now that the merger is complete, content sweetening eventually closes the loop on the issue of the team players. This is why Tom Jermoluk recently announced that missions will succeed. The multimedia next generation system gets your input on price-performance technologies. We're going forward on a binary-compatible next generation system.



© 2007 Cheryl D. Wise





229

230

CHAPTER 8 ■ BRANDING YOUR WEBSITE

If you are using your own content, replace the headings, list, and paragraphs inside the elements with your own content. Save the page as chapter8.html.

■Note In Design view, you may see a gap at the bottom of the page, but you will not see the gap when the page is displayed in a browser. Although the Expression Web rendering is very good, it is not always identical to what you will see in your browser.

Maintaining Your Branding Throughout Your Site Once you have decided on your site’s branding, you can keep the look and feel consistent by retaining as many of the elements as possible in your external stylesheet. Once you are satisfied with the page display, create an empty stylesheet with a meaningful name using File ➤ New ➤ CSS to create a new empty stylesheet. Although site.css is a name that is descriptive when you have more than one website, it will not tell you which site the site.css stylesheet applies to. My preference is to name the stylesheet after the domain. That way if I am using Windows Desktop Search or some other search to locate a file (particularly in backup folders), I can tell at a glance the site to which it belongs. Drag your new empty stylesheet to your chapter8.html page. Now you will see two CSS sections in the Manage Styles task pane. Select all the styles in Current Page section, and drag them to the external stylesheet section, as shown in the “before” and “after” of Figure 8-23.

Figure 8-23. Move styles from the page to your external stylesheet by dragging between the sections.

CHAPTER 8 ■ BRANDING YOUR WEBSITE

Although a stylesheet can go a long way to keeping your website branding consistent from one page to another, it cannot keep the page structure consistent. elements must still be in the HTML.

Summary In this chapter, you have used color and images to create a distinctive look and feel for your website. You created a masthead to make an immediate visual connection between your pages with a consistent navigation menu. Once you have created your site’s look and feel, move your styles to an external stylesheet. This is one half of the equation in keeping the pages in your website consistent. The other half is to use a template with locked regions where you want the pages to be the same but still allow new content to be added to the content regions. In the following chapter, you will create a dynamic web template based on the page you just created.

231

CHAPTER

9

Dynamic Web Templates I

n the last chapter, we started creating an identity for your website. Keeping those branding elements consistent from page to page is helped by the use of an external stylesheet. But a stylesheet cannot prevent changes to the page caused by adding or removing content. This is where templates come into play. A template provides the common HTML used on all of your website’s pages. Templates can be divided into three types. The first is little more than a reference page that you save under a new name to create your new pages. Many of the commercial templates you can buy are of this type. The second type is a server-side template where content is inserted into sections of a web page when the browser requests the page. You see this type of templating in content management systems. Master pages are a variation of the server-side templates we will be covering in Chapter 13. The third type of template is a Dynamic Web Template (DWT). When you use a DWT areas of the page that need to remain unchanged from one page to another are locked. At the same time, your content areas can be edited without worrying about breaking the common sections of your page. Unlike the other two types of templates, no processing or specific technology on the server is required. This means you can use a DWT in any hosting environment, even those that do not support scripting.

DWT Overview DWTs started out as Dreamweaver Web Templates but proved to be so useful that other companies jumped on the design-time template bandwagon. The first Microsoft web program to support them was FrontPage 2003.

What Does a DWT Do? Often, when you create a web page, many areas of the page will not change from one page to the next. Generally, these include the masthead, footer, and primary navigation menu. This is where a DWT comes in—with locked areas that will stay the same from page to page within your site and editable regions where the individual page content will go. When you create a DWT, the entire page is locked. Then, you select the areas on the page that will change from page to page and mark them as Editable Regions.

233

234

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

One of the primary benefits to using a DWT is consistency between the pages on your site. When you apply the DWT to a page or create a new page using the DWT, you cannot accidentally change, move, or break the parts you want to remain the same throughout your site. This safety net is only one of the benefits of a DWT. Another benefit comes when you want to make a global change such as adding another section to your menu or updating copyright or contact information. With a DWT, any change made to the locked regions of the template will be propagated to every page that uses that template. If, for example, all the pages were marked with “copyright 2006”, and it is now 2007, you can make the change to “copyright 2006-2007” with a simple edit of the template. Once you save the template, all the pages will be updated. In the preceding example, you may think, “What is the big deal? Using Find and Replace will do the same thing, so why bother with a template?” The copyright example is a minor change, but you can make far more substantial changes to your site without directly touching the code of a single HTML page. Assume, for example, that your site is using a two-column layout with a top navigation bar, and you now decide that you want to move the navigation to a side column. Or maybe you have decided to add a third column for Google AdWords, other sponsorship, or advertising information. You would make the necessary changes to your DWT; then, when you save, all of your pages will be updated to reflect your new additions or subtractions.

■Caution DWTs are strictly a design-time feature. When you make a change to your DWT, you must republish every page that uses it.

Creating the DWT I will be using the page we created in Chapter 8 to create the DWT; you can follow along with the same page or use one of your own. The first step in creating a DWT is to open the page you will be converting to a DWT in Expression Web. Then go to File ➤ Save As, and select DWT from the drop-down menu as shown in Figure 9-1. Use your site name for the DWT to help you distinguish one DWT from another. Here, I saved it as few-site.dwt. I recommend saving it in a new folder called Templates. While it does not matter to Expression Web where you save your DWTs, putting your templates in a Templates folder will make it easier to keep track of your templates as your site grows. Normally, I would tell you to use lowercase folder names, but in this case, I use the uppercase “T,” because Dreamweaver always uses a capital T for the template folder, and Expression DWTs should work in Dreamweaver. DWTs are design-time tool and do their updates in Expression Web. As a result, it is not necessary to upload your DWTs. After you have saved the file as a DWT, code for an editable region called doctitle will be added to the section. In Code view, your page looks like Figure 9-2.

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Figure 9-1. The open page you will be converting to a DWT

Figure 9-2. Only one editable region for the page title is created by default.

This is the only editable region inserted in a new DWT at the time it is created. In order to use your new DWT, you must add more editable regions in the section of the page. You should also add one or more editable regions in the section.

235

236

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Adding Editable Regions Our next step will be to add an editable region to the area of the page where our page name or will go. The easiest way to do this is to highlight the area you want to be editable. In our few-site.dwt, that would be the main content section below the menu. Select all the content that you will be replacing on your pages in the main section. Next, right-click and select Manage Editable Regions, as shown in Figure 9-3.

Figure 9-3. Select Manage Editable Regions to add content regions.

This brings up the Editable Regions dialog box (see Figure 9-4), which adds the editable region code to your web page. Here’s a bit of information on each section: • Region name: Give a bit of thought to the naming convention you decide to use. Using a consistent naming convention will make it easier for you to move from one template to another in the future. • Other regions on this page: This section shows you the names of other regions on the page.

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Figure 9-4. Type in the name for your region to activate the Add button.

You can only add editable regions when you have highlighted a section in Design view. You can remove regions at any time from this dialog box, which can also be launched from the menus by using Format ➤ Dynamic Web Template ➤ Manage Editable Regions. If you are not sure where an editable region is on your page, select the region name to activate the Go To button, which highlights the editable region on your page. Whenever your cursor is in an editable region, that region will be outlined in orange, and the region name will appear at the top left of the region. In Figure 9-5, you can see that I have added an additional editable region to the left-side column.

Figure 9-5. Editable regions will always be outlined in orange by default.

237

238

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

The regions in the DWT are now as follows: • doctitle: Surrounds the element • sidecol: A side column, which in this layout is on the left (the orange outline is difficult to see in this image) • content: The main content section

Exercise 9-1. Creating Editable Regions in the Body Region In this exercise, you will create editable regions in the body section of your DWT: 1. If you have not done so, open the page that you wish to turn into a DWT, and select File ➤ Save As and then select Dynamic Web Template (*.dwt) from the Type drop-down menu. Click the Save button. 2. Next, look at your web page, and decide which elements on the page will change from one page to the next within your site. There should be at least two sections of the page that you will want to change: • The page name or section of the masthead that tells the visitor about the contents of the web page • The main content area, where the content unique to each page will be placed • Possibly additional areas of the page you want to make editable, if you have a multiple column layout 3. Once you have decided where your editable regions should be placed for each region, highlight the first area to become part of your DWT’s editable regions in Design view. 4. Right-click the highlighted area, and select Manage Editable Regions. 5. Type in the name of your choice—make sure it is descriptive so when you are creating new pages in the future, you will know what should go in each editable region. 6. Click the Add button. Once you see your new region in the “Other Regions on this Page” area, close the dialog box. 7. Repeat steps 3 to 6 for each of editable regions you wish to add to your DWT. 8. Save your DWT. You now have a DWT that can be used on your website to keep the look and feel consistent among pages.

Editable Regions in the Section So far, all of the editable regions we have added were in the visible part of the web page. This is because in Expression Web, there is no WYSIWYG way to add editable regions in the section of the page other than the default doctitle region; see Figure 9-6.

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Figure 9-6. More that one editable region in the head section of the page is a good idea. The default doctitle editable region surrounds the element, which means that any elements, page-level styles, or scripts must be in that same editable region. Notice in Figure 9-6 that the stylesheet link is below the doctitle editable region. This can prevent page-level styles from being applied under CSS rules of inheritance. To ensure that your page level styles maintain their priority, you need to add another editable region below the stylesheet link in the section of your page.

Exercise 9-2. Adding an Editable Region to the Head Section The only way to add editable regions for elements or page-level scripts and styles is to copy and paste the template code and manually change the name of the editable region. Use the following steps to add an editable region to the head section of our example: 1. Add a metadescription to the page before creating your new editable region by right-clicking anywhere on your page and using the Page Properties dialog box, shown in Figure 9-7.

Figure 9-7. Add your site meta-tags to the DWT before you add editable regions in the section.

239

240

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

2. Check to make sure that when Expression Web added your tags they were put where you want them to be. You also will need to decide whether or not you want two separate editable regions, one for elements and another for style and script blocks. Whether you have one region or two is a matter of personal preference. If you choose to have separate regions, you can put the elements between the and the stylesheet link. My preference is two separate regions, so I’ve put the elements in with the element and have only one additional editable region in the . 3. Highlight all the code starting with through paste it just above the element. Next, in the new copy, replace the and elements with an HTML comment using the keyboard shortcut of Ctrl + / (or using the menus: Edit ➤ Code View ➤ Insert Comment) as a placeholder. Then, double-click doctitle to rename the second editable region instance headblock. 4. In Figure 9-8, you can see the headblock region that was just created.

Figure 9-8. A section with two editable regions Your Editable Regions dialog box should now look like the one shown in Figure 9-9.

Figure 9-9. Complete list of available editable regions 5. Save your DWT.

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Now that you have created a DWT, the next step is to attach the DWT to web pages that your visitors can view. DWTs will display when you use Preview in Browser from Expression Web but usually do not display if you try to view the page on your live site.

Attaching DWTs to Your Web Pages A DWT must be attached to your web pages before the DWT can manage the common content and the look and feel of your site. In Exercise 9-3, you will attach the DWT you created in the previous exercise to existing pages, and in Exercise 9-4, you will create new pages directly from the DWT. We will begin with attaching a DWT to an existing page.

Exercise 9-3. Applying a DWT to an Existing Page In the last chapter, we created new, empty HTML pages when our menu was created. We will use one of those pages to apply the DWT you created in Exercise 9-2 to an existing page with no content: 1. Open the about.html page that you created in Chapter 8. The page will be without a title or content, as shown in Figure 9-10.

Figure 9-10. Pages created using the Edit Hyperlink dialog box have no content. 2. To attach a DWT to an existing page, you use Format ➤ Dynamic Web Template ➤ Attach Template to page, which will bring up the Attach Dynamic Web Template dialog box, shown in Figure 9-11; choose the template created in Exercise 9-2. Click Open or double-click the DWT you want to attach.

241

242

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Figure 9-11. Select the template you want to apply to your page. 3. Selecting the template may bring up the warning shown in Figure 9-12 if you have a doctype or serverside scripting in the page you are applying the DWT to. If all you have is a doctype, it is safe to ignore the warning. If you have server-side script, make sure you have a backup of the page, since in some cases, server-side scripting may be removed when applying a DWT.

Figure 9-12. Applying a DWT to a page can remove scripting or other elements. 4. Expression Web will also notify you that the page is being updated, as shown in Figure 9-13.

Figure 9-13. Whether the warning appears or not, you should always get the processing box. 5. Save your page. You page should now look just like the original DWT, since there was no content on the page to replace the default editable region content.

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Once you have attached your DWT, you will be able to replace the content inside of the editable regions, outlined in orange, but you will not be able to change the content outside of your editable region. Instead, as shown in Figure 9-14, your cursor will indicate that the region is not editable.

Figure 9-14. The following symbol will appear when you are over a locked portion of the template: Make sure that you replace the default template content with content that is appropriate for the page.

■Note You can also apply a DWT to an existing page by dragging and dropping the DWT file on to an existing page.

Exercise 9-4. Creating New Pages from Your DWTs To create a new page from the DWT, use one of the following methods: 1. Use File ➤ New ➤ Create from Dynamic Web Template, as shown in Figure 9-15, and save the file in the location of your choice.

Figure 9-15. Creating new pages with a DWT that is already attached.

243

244

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

2. Or, you can start with a new blank page, created by double-clicking the new page icon, as shown in Figure 9-16.

Figure 9-16. Double-clicking the new page icon will create an HTML page.

a. Double-click the new page icon on the format tool, which opens an empty blank page. Save it with your file name in the location of your choice before you go any further. Save the page with a name that reflects the contents you will be adding to the page. By saving the file before you add the DWT, your image and other file location references will be correct when the DWT is applied. b. Drag the DWT from the file list, and drop it on the opened page to apply the template to the page and give you a dialog box that tells you the page was updated, as shown in Figure 9-17. c. Save again before you begin adding content.

Figure 9-17. The links.html page now has the DWT applied.

3. The final method for creating a new page using an existing DWT is to open a new blank page and use Format ➤ Dynamic Web Template ➤ Attach Dynamic Web Template, which will apply the template to the open blank page. This will give you the same dialog box as the drag method (see step 2).

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Attaching a DWT to an Existing Page In many cases, you will have an existing page or site that you will want to use with a DWT. In this section, we will apply the DWT to an existing page on the site, one that already has sections of the page duplicated in our template. Before making a major change to your site, you may want to back up the entire site by publishing it to a new location on your hard drive. Even if you have a complete site back-up before you start to convert any existing page with content, make a copy or save the page with a new name so that you have an easily accessible backup of the file if you make an error while converting it.

Preparing an Existing Page for a DWT We will use the structural.html page from the earlier chapters to demonstrate how to apply a DWT to an existing page that already has a masthead and other styles applied. Follow these steps to prepare the page for the DWT: 1. Start with a back-up of your structural.html page, as shown in Figure 9-18.

Figure 9-18. Remove the content that is contained in the template’s locked regions. 2. Now that you have a copy, open the file you want to convert. (In your real web site, you would use the original web page, not the copy.) You will need to remove any content that is duplicated in the locked regions of the template or move it to other sections of the page. Otherwise, you will end up with a page that looks like Figure 9-19.

245

246

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Figure 9-19. Notice the menu is duplicated as is the copyright information from the footer. As you can see in Figure 9-19, the masthead and other areas were repeated inside our main content area. The repeated sections look a bit different, because they do not contain all of the same format information. Since an ID is only to be used once on the page, Expression Web has renamed the duplicate divs by adding a “0” after the ID, as illustrated in Figure 9-20, where masthead div was renamed footer0.

Figure 9-20. Duplicate IDs are not allowed, so Expression Web will add a number to prevent duplication. Notice that the areas locked by the template are highlighted in yellow in Code view. If you have form fields or other items with a name attribute, those too will be changed by adding a “0.”

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

3. To avoid this problem, before you apply the DWT remove the original footer div completely, click the section that needs to be removed, select the

from the Quick Tag bar, and press the Delete key. 4. If you need to keep the content of an element such as a div while removing the div container, select it from the Quick Tag bar, as shown in Figure 9-21, and select Remove Tag.

Figure 9-21. You can remove the HTML tag without deleting the contents from the Quick Tag bar. 5. Repeat steps 3 and 4 with any of the remaining divs you are replacing with content from your DWT. Save your page.

Applying a DWT to a Page with Content Now that the page has the content that will be replaced by locked regions in the DWT, it is time to apply the DWT. Your page should look like the one shown in Figure 9-22.

Figure 9-22. Content in the section will be replaced.

247

248

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

■Note All style and scripting in the section will be replaced, which is another reason to make a backup before you apply your DWT.

Use the following steps to apply your DWT to a page with existing content: 1. To attach a DWT to an existing page with content you can employ the same methods used to apply one to a new page. Whether you drag the template from the folder list and drop it on the open page or use Format ➤ Dynamic Web Template ➤ Attach Template to page, if there is more than one editable region within the body of the DWT, Expression Web will select the first editable region in the body section for your content. If that is not where you want the content to go, you will need to tell Expression Web where to place the body content, as shown in Figure 9-23.

Figure 9-23. Use the Modify button to change the default Editable Region to the region of your choice.

■Note This may also bring up the warning shown in Figure 9-12 if you have a doctype or server-side scripting in the page. The same advice applies: if it is a doctype, it is safe to ignore the warning. If you have server-side script, make sure you have a backup of the page, since in some cases, server-side scripting may not be compatible with a DWT.

2. By default, Expression Web selects the first editable region in the body of the page as the place to put all the content. In this case, it has picked the side column region as the default, but you would not want to have the entire page contents in the sidebar. At this stage, there is no way to choose what part of the text will go into which region. You can only choose one region to place all the body text into. Use the Modify button to select the content region, as shown in Figure 9-24.

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Figure 9-24. Generally, you should choose your main content area when you first apply your template. 3. Since the majority of the content should go into the main content region, we will need to change from the default to the one we wish to use by selecting it from the New Region drop-down menu.

Moving Content Between Editable Regions Now that the template is applied, the page in Design view has all of the content in the main editable region and should look like the one shown in Figure 9-25.

Figure 9-25. The page and elements were moved like the page contents to an editable region in the DWT.

249

250

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

The and elements were preserved when the DWT was applied, but the style blocks in the section were replaced by the template styles. If you have page-level styles that you need to keep, make sure that you have a backup before you apply the DWT. Notice that the editable regions that were not mapped to the body content have the same text as in the DWT. To move the content to appropriate places, use normal editing procedures such as cut and paste. Make sure that you get all the HTML tags when you move them around.

■Tip To avoid the possibility that an editable region will collapse and make it difficult to add content to that region, make sure that there is at least a nonbreaking space ( ) or comment inside every editable region.

After the Template Has Been Applied Once you have moved your page content to the appropriate editable regions, the page will look like the one shown in Figure 9-26 when viewed in a browser.

Figure 9-26. Your page now matches your new site design and will be updated when changes are made to your DWT.

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Editing a DWT Once you have a DWT, there will be occasions where you will need to change some of the locked areas. One typical reason is to add or remove items from the navigation area. When we created our DWTs, only some of the links would take users to real pages; others were just placeholders in the menu. In the next exercise, real links will be added. Editing a DWT is no different than editing any other page with one slight caveat—only changes outside the editable areas will be updated on the pages attached to the DWT.

Exercise 9-5. Updating Pages Attached to a DWT In this exercise, we will edit the links in the DWT’s menu and update all the pages attached to the DWT using the following steps: 1. The menu in our DWT still has null links. Now that we have created pages for the rest of our website, we can update the links. To update links, open the DWT, and edit it as you would any HTML page. In this case, we would be adding real links to the menu, as shown in Figure 9-27.

Figure 9-27. Edit the DWT as you would any HTML file.

2. Once you have made the changes to the DWT, save it. This time, instead of the update confirmation prompt, you will receive a dialog box, shown in Figure 9-28, telling you how many pages are attached to the DWT and asking if you would like to update them.

251

252

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Figure 9-28. You will have visual confirmation of the number of pages to be updated.

3. To apply the updates, click Yes. If you have more changes you wish to make to the DWT, you can click No to wait to apply the changes until you have completed the ones to your DWT. Once you have applied the pages you will get a notice that files have been updated, as shown in Figure 9-29. If, for some reason, a file could not be updated, you will be notified of that as well.

Figure 9-29. The number in the updated pages notification should match those in Figure 9-28.

If the number of pages in Figures 9-28 and 9-29 do not match, place a check mark in the Show Log box to find out what pages did not update.

Detaching a Page from a DWT At times, you may not want to update a page attached to a DWT to reflect changes to your template; pages that are being archived and replaced with updated information would be one such case. To avoid accidentally updating those pages in the future, you should detach the page from your DWT. When you detach a page from its template, the look and feel remain the same; only the template mark-up is removed which prevents it from being updated to reflect changes to the DWT. With the page to be detached open, select Format ➤ Dynamic Web Templates ➤ Detach from Dynamic Web Template to detach the page so that the entire page becomes editable again, as shown in Figure 9-30.

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Figure 9-30. Detaching a template is a one-step operation.

When your page is viewed in either Design view or your browser, the page should look exactly the same as it did when attached to the template. The only difference is that it will no longer be updated when changes are made to the DWT.

Changing the Attached DWT There will be occasions when you will want to change the DWT that is attached to your web page, perhaps in the case of a major redesign from one type of layout to another. For the purpose of showing you how to change the DWT that your page is using, I’ve created a second DWT with an additional editable region named ads. The content region name is now maincontent. This DWT was saved as few-site3.dwt. If you want to follow along, you can either add another editable region to your existing template or download few-site3.dwt from http://foundationsofexpressionweb.com/exercises/chapter9. Follow these steps to change the DWT attached to your page: 1. Begin with the page shown in Figure 9-26. Drag the new DWT from the Folder List, and drop it on the open page in Design view. Since there is already a DWT applied to the structural-bak.html page and the editable regions do not match exactly, we are presented with the opportunity to determine where the content of each region should go, as shown in Figure 9-31. As when you initially applied the first DWT, by default, Expression Web will put the unmatched content in the first editable region inside the body element.

253

254

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

■Note You can also change the DWT attached to your page by using Format ➤ Dynamic Web Template ➤ Attach.

Figure 9-31. Use the Modify button to remap the current content section. 2. Using the Modify button will allow you to choose the correct editable region to move your content to in the new DWT. 3. Expression Web will update your page when you click the OK button. Once the template change has been completed, you will see the update confirmation box shown in Figure 9-23. With the new DWT applied, our page now looks like the one shown in Figure 9-32.

Figure 9-32. The new region for advertisements or notices is ready for content.

CHAPTER 9 ■ DYNAMIC WEB TEMPLATES

Summary Dynamic Web Templates (DWTs) are one of the features in Expression Web that will help you manage your website and keep a consistent look and feel throughout it. The primary advantage of using DWTs is that they are server independent, so they can be used on a wide variety of servers without regard to which, if any, server-side processing is available to you. DWTs present a slight disadvantage when compared to templates processed by the server, since you have to upload all the files that are changed when you edit your DWT, but if you use the synchronize button when you publish, Expression Web will ensure that all changed pages are published. In the next chapter, we will add interactivity to our website by creating forms.

255

CHAPTER

10

Forms A

t some point, almost every site other than a purely personal one will use a form somewhere within it. The form may be as simple as a contact form, or it may be part of a database-driven section or a content-management system. Expression Web has several built-in tools to help you create forms and collect the form results. Whether you are using the form to send e-mail from site visitors or to update and maintain a database, Expression Web has a tool to make your job as the website designer easier. There are two basic types of forms you can use in Expression Web. The first is traditional HTML forms, which are sent to a script for processing. If you are using a web server that does not support ASP.NET 2.0, you would use this type of form. The second type of form uses ASP.NET 2.0 form controls and passes information directly by using a postback or calling a function on a .ascx page. Whether you are using HTML elements or ASP.NET form controls, the basic method of creating a form is the same. In the first part of this chapter, we will be using HTML elements. In the second part, any differences using ASP.NET form controls will be addressed. As we create our form, we will also cover ways to improve the usability of your forms and make them accessible to visitors using alternative access devices and screen readers.

Required Elements for a Form Regardless of the method used to create a form, certain components must be included in order for a form to function as follows: • Form element: In the , you set the action that happens when a user submits a form and specifies the form name. • Form field: There are many types of form fields, ranging from text boxes to radio buttons and check boxes. • Submit button: Use this button to send the form to the form handler. Expression Web makes it very easy to create your own form by dragging elements from the HTML or ASP.NET section of the Toolbox. When the Form Controls section is expanded, as shown in Figure 10-1, you can see a list of the available form field types, as well as other form-related options available for you to insert on your web page.

257

258

CHAPTER 10 ■ FORMS

Figure 10-1. Toolbox HTML Form Controls

■Caution Form field names are for your server-side processing; they do not show as labels on the web page.

To access the dialog boxes to set the properties for each of the form fields, you will need to right-click the form control after you drag it from the Toolbox to your page. The Form Field Properties dialog box is where you set the field name and any options that are appropriate for the type of form control you will be using.

NAMING YOUR FORM FIELDS You should decide on a naming convention that you will use on all your websites. A consistent convention will make it easier to know what the fields do when you come back to update your pages. By the same token, you should use descriptive names, such as firstname or fname, instead of the default text1. There are reserved words that you should never use for form field names, since they are used by serverside processing scripts and/or databases to perform specific tasks. The following list provides some of the reserved words that you might use as a descriptive name without realizing the word is reserved: • date • desc

CHAPTER 10 ■ FORMS

• end • false • from • name • number • state • time • true For a more complete list, see http://msdn.microsoft.com/library/default.asp?url=/ library/en-us/tsqlref/ts_ra-rz_9oj7.asp. Form fields should always have a label associated with the form field. Using a label with check boxes and radio buttons is especially important. If you have ever had difficulty selecting the correct radio button or checking a small check box, you will appreciate that using the element provides a larger clickable area. This is both a usability and accessibility feature.

Red A check box using the preceding label syntax means that double-clicking the name “red” or tabbing to it and using the spacebar will check or uncheck the box. A common practice is to use the control name or in the case of a check box the value prefixed with lbl for the label ID.

Let’s go through some of the form controls: Advanced Button: The primary difference between the Advanced Button form control and the Input (Button) control is the ability to set height and width, as shown in Figure 10-2.

Figure 10-2. With the Advanced Button Properties dialog, you can set the height and width of a button.

259

260

CHAPTER 10 ■ FORMS

Drop-Down Box: This control is used to create a drop-down list of choices. Figure 10-3 shows the Add Choice dialog box as well as the Drop-Down Box Properties.

Figure 10-3. Add choices to your drop-down form field. Group Box: This creates a fieldset to contain related form fields. In the following example, an Expression Web Group Box control was used to wrap a fieldset around a series of check boxes. Fieldsets serve an important accessibility function, since they tell screen reader users that the fields are related by reading the before reading the form controls, while the border does the same for sighted visitors. Figure 10-4 shows setting the fieldset legend text or, as Expression Web calls it, the Label using the Group Box Properties dialog, which creates the fieldset around the field group.

Figure 10-4. Create a fieldset by using the Group Box control from the HTML Toolbox form control.

CHAPTER 10 ■ FORMS

Here’s the resultant code:

Colors Red Blue Green

Figure 10-5 shows the resulting display in a web browser; note the thin outline surrounding the group of related check boxes.

Figure 10-5. When a fieldset is used, a faint outline will be displayed in the browser.

Input (Button) lets you insert a button that will be sized based on the text displayed in the Values/label text field. Figure 10-6 shows the Push Button Properties dialog box, which is the same dialog box displayed for the Input (Reset) and Input (Submit) buttons. The only difference is which of the three radio buttons is selected by default.

Figure 10-6. Basic button choices Input (Checkbox) toggles the field as either off (unchecked) or on (checked), as shown in Figure 10-7.

261

262

CHAPTER 10 ■ FORMS

Figure 10-7. You can select a default state for your check box.

■Tip Unlike most input controls, check boxes and radio buttons can share the same control name so that your results are grouped when you receive them.

Input (File) opens the File Upload Properties dialog that allows you to add a box for a file name and a browse button to allow users to select a file to submit with the form. Make sure that your form destination is writable. Its properties dialog is shown in Figure 10-8.

Figure 10-8. File uploads require you to have write permissions on the destination folder.

Input (Hidden) is a control that users can’t see in their browser (but can see in the source code), which submits information with the form. There is no form properties dialog box available for this control, so the name and value must be set in Code view or by using the Advanced button on the Form Properties dialog box, as shown in Figure 10-9.

CHAPTER 10 ■ FORMS

Figure 10-9. Use the Advanced Form Properties dialog box to add hidden field name and value pairs.

Input (Image) opens the Picture Properties dialog, which allows you to use an image as a submit button, as shown in Figure 10-10.

Figure 10-10. The same dialog box to name the button and select the image appears whether you select Picture Properties or Form Field Properties from the right-click menu.

263

264

CHAPTER 10 ■ FORMS

Input (Password) is a single-line box for users to enter a password. The password is hidden, usually with asterisks displayed in the browser. The field and its form field properties are identical to Input (Text) with the exception of which button is selected for the text box type, as shown in Figure 10-11.

Figure 10-11. A password text box is a text box where the input is replaced by asterisks and not displayed in the browser.

Input (Radio) creates radio buttons. Radio buttons are exclusive, that is only one button in a group of radio buttons with the some name can be selected at a time. If you want to allow multiple choices to be selected, use a check box instead. Because radio buttons are small, it is very important that you use a label with this type of form field. For a group of buttons, make sure that you use the same group name in the Option Button Properties box, shown in Figure 10-12, and a fieldset to group them, as we did with the check boxes in Figure 10-4.

Figure 10-12. It is usually best not to start with a radio button selected when you have more than one choice.

Input (Reset) creates a button that resets the form (see Figure 10-10). Input (Submit) creates a button that submits the form (see Figure 10-10). Input (Text) creates a single line box for users to enter text (see Figure 10-8).

CHAPTER 10 ■ FORMS

Label adds a label to describe another form control. Select the form element you want to label, right-click Label in the HTML Toolbox Form Controls section, and select Wrap, as shown in Figure 10-13.

Figure 10-13. To enclose your selection with a label, use Wrap, not Insert.

Text Area creates a large box for users to enter text; you specify the height and width of a text area in rows and characters (see Figure 10-14), which are wider than most text characters. Make sure you have enough space on your page, or you may end up with a horizontal scrollbar in your browser.

Figure 10-14. Don’t forget to check the width of your text box in your browsers.

265

266

CHAPTER 10 ■ FORMS

Exercise 10-1. Creating a Simple Contact Form In this exercise, we will create a simple contact form allowing your visitors to send you feedback from your website: 1. Create a new blank page, and save it as form1.html. Add Contact Us text, and make it an . 2. To create the form, drag the Form control from Toolbox ➤ HTML ➤ Form Controls, and drop it in Design view just below your page title. 3. Next, inside your form, type Name:, drag out an Input (text) control, and drop it to the right of the text. 4. Select the input, and right-click to launch the Form Field Properties dialog box, as shown in Figure 10-15. Name your text field sname, short for “sender name,” and click OK. The name attribute is necessary to send your form’s field value to your form’s processor and for older browsers to associate the label with the form field. For modern browsers, you should also add id="sname" using the Tag Properties task pane or the Quick Tag Editor.

Figure 10-15. Change the form field name before you add a label. 5. After your text field has been renamed, wrap a Label control around the text by selecting the text, rightclicking Label in the Toolbox, and selecting Wrap, as shown in Figure 10-16.

Figure 10-16. Highlighing the text and the form field will wrap the label around the selected items.

CHAPTER 10 ■ FORMS

6. The resulting code will look like this:

Name: 7. We now need to associate the label with the form field. Right-click in the Quick Tab bar, and choose Edit Tag, as shown in Figure 10-17.

Figure 10-17. Edit the label to associate it with your name text box. 8. When the Quick Editor is launched, change the label ID from lable1 to lblsname, and type for="sname" or choose for from the IntelliSense drop-down, as shown in Figure 10-18.

Figure 10-18. Associate the label with the form field using Quick Editor. 9. We are using the for attribute instead of wrapping our form fields with the label so that we can style the form once it is finished. By changing the id from the default to lbl[field_name], we are able to keep track of which label goes with each field. You can associate more than one label with an individual control.

267

268

CHAPTER 10 ■ FORMS

10. Use Shift+Enter to start your next field on a new line. Next, add a text box for an e-mail field.

■Tip Use your right arrow key or your space bar after you have finished wrapping your selected content in a label before you start a new line to make sure that the label doesn’t continue to the next line as well.

11. Add another line break, and type Message: followed by a TextArea control, as shown in Figure 10-19. Adjust the default size to give your visitors visual room to write in their messages, but make sure you preview it, since it may be wider than you think.

Figure 10-19. Use the TextArea Box Properties dialog to create the e-mail field. 12. Now, add a submit button on a new line at the bottom of the using Input (Submit). Following the process described in steps 5–10, add labels to all the input fields except the submit button; a label is not needed on a submit button. The finished form should look like the one shown in Figure 10-20.

Figure 10-20. The unstyled contact form is not very attractive. 13. The final step in this exercise will be to style our form so that it is more visually appealing. By styling the label element, we can correctly line up all of our fields except the submit button, which does not have a label. You can create a class with padding on the left side to match the width of the elements if

CHAPTER 10 ■ FORMS

you wish. However, because of differences in how the browsers calculate margin and padding, the submit button may be in slightly different locations depending on the browser you are using. An alternative is to place the submit button in a new paragraph and use text-align: center; to center the submit button in the form box. Use the following CSS style definitions: form { border: thin solid #000000; padding: .5em; margin: 1em auto 1em auto; width: 25em; background-color: #CEDBAE; font-weight: bold; } label { float: left; padding-right: .5em; width: 5em; text-align: right; font-weight: bold; } .submit { font-weight: bold; text-align: center; } 14. Apply the submit class to the

holding the submit button. When viewed in a browser with the preceding styles applied, your form should now look like the one shown in Figure 10-21.

Figure 10-21. Styled using just HTML elements and one class, the form now looks good. 15. Use different background colors, fonts, and other style properties to create the form presentation you desire.

269

270

CHAPTER 10 ■ FORMS

The HTML form fields we have just used will allow you to create a wide variety of forms, but unless the form is connected to a forms processor, the information collected will be lost in cyberspace. The next section will connect our forms to a server-side processing script to do something with the information collected.

Processing Forms Normally, a form handler is some sort of server-side script. Some Expression Web users will be migrating from FrontPage and will have been using the FrontPage Server Extensions (FPSE) to process their forms. If your web host offers FPSE, you do not need to know how to write a server-side script; Microsoft has included some common form-processing tasks using webbots. The Form Properties dialog box is also where you would be sending your HTML form results to a custom script. You set these options via the Form Properties dialog box, as shown in Figure 10-22.

Figure 10-22. The Form Properties dialog is where you specify what you want Expression Web to do with the collected form information. If you are hosting on a web server that supports ASP.NET 2.0, you should use the ASP.NET Form Controls, covered in the “ASP.NET 2.0 Form Controls” section later in this chapter, instead of the forms processing covered in the following section.

Setting Form Properties First, we will be using FPSE to process the web form to send the result by e-mail. Right-click anywhere inside your form, and select Form Properties to launch the Form Properties dialog box. The options you can set in the Form Properties dialog box follow:

CHAPTER 10 ■ FORMS

• Send to File name: This is the default action that will send the form results to a text file using a comma-separated values format. Unlike FrontPage, Expression Web will not create the _private directory with the correct permission in which to store your file results. You will need to create one yourself locally if you have not downloaded one from your hosted site. Web servers are normally configured so that folders beginning with an underscore are not served to the browser directly. This security depends on the server being configured correctly, so do not rely on it for sensitive information. • Send to E-mail address: If you want the form results to be sent by e-mail, place the e-mail address in this box. You can send a copy to multiple e-mail addresses if you separate them with commas, but there have been reports that this is buggy; it is better to daisy chain forms to send them to multiple e-mail addresses. Unfortunately, the current webbot will include your e-mail address in the code, which makes it accessible to form-processing bots. Avoiding having your e-mail address harvested is one of the benefits of using a form instead of using mailto:email as the action on the element. When you do this, Expression Web will give you a warning that this action requires FPSE to function, as shown in Figure 10-23.

Figure 10-23. FrontPage Server Extensions are required to use this Send to E-mail address method.

271

272

CHAPTER 10 ■ FORMS

Click No; otherwise, the e-mail address will be removed, and you will not receive the e-mail. Until the form is published to a web server with FPSE installed, you will see a warning, when you save or preview locally, that a web component is being used that requires the FPSE. You may use both the send-to-file and send-to-e-mail options simultaneously. This provides a backup of the form information in case there is a problem with receiving the e-mail. (If you have spam filters set up, make sure the from address the form uses is whitelisted.) • Send to database: This option is only available on a Windows server. When this option is selected, you need to use the Options button to specify the database and connection information. If you do not have an existing database, Expression Web creates an Access database to receive the results of the form when you follow the prompts. Since FPSE is being phased out, it is better to use ASP.NET 2.0 for new databases. • Send to other: This is usually your best option for secure forms processing that does not expose your e-mail address to bots for harvesting. Many web hosts have preinstalled scripts available. Usually, those are something like CGI Formmail. Other options include sending the form results to an ASP or other custom script. • Form name: Give your form a name that will allow you to keep track of the form’s purpose instead of using the default Expression Web name. • Target frame: If you are using a frameset, this allows you to send the results to a specific target or . • Options: The dialog box that appears when you use this button will vary depending on the radio button selected. The primary dialog boxes triggered follow: • Saving Results: This dialog box responds to the “Send to File name” or “Send to E-mail address” radio buttons. • Options for Saving Results to Database: This one responds to the “Send to database” radio button for specifying your database connection or creating a new one using the FPSE. You do not create ASP.NET 2.0 connections using this method. • Options for Custom Form Handler: This dialog responds to the “Send to other” radio button. This is also where you set whether your form will send the results in a URL string or hidden in the file headers, where the visitor cannot see or save them. • Advanced: This triggers the Advanced Form Properties dialog box, where you add hidden fields that the visitor will not see but that contain information that transfers data to the forms processor, as shown in Figure 10-9. If you use one of the FPSE bots to handle your forms processing, all you need to do is follow the prompts. If you are using a custom script, consult the documentation that comes with your script. To send the results of the form we created in the preceding exercise, set your form result options as shown in Figure 10-24.

CHAPTER 10 ■ FORMS

Figure 10-24. This sends results to a classic ASP page for processing. Let’s have a look at a couple of forms-processing scripts, starting with sendmail.asp.

ASP Send with CDO If you are hosted on a Windows 2000 or Windows 2003 server, you can send e-mail using Classic ASP and CDO. Listing 10-1 shows sendmail.asp, which will send your form1.html results to the e-mail address you specify. Make sure that you create a thankyou.html page. To use the following ASP code, you must be hosted on a Windows server that supports CDONTs. Check with your web host; your host may have a different method such as ASPEmail or ASPMail that you should use instead.

■Note Replace [email protected] with the e-mail address you want the form sent to. You can change the subject line to the one of your choice.

Listing 10-1. A Classic ASP Page for Processing Our Contact Form



Thank You

Thank You

If your message:



""



Requires a response it will be sent to



If you are hosted on a Linux server, you cannot use ASP to send your mail, but in most cases, you can use PHP.

PHP Send Mail The code in Listing 10-2 will send results from our simple contact form using PHP and display a thank you page to your site visitor. Change the action of the form to sendmail.php, and copy the following code to a page named sendfile.php. Otherwise, the instructions are the same as for the previous ASP method.

■Note Replace [email protected] with the e-mail address you want the form sent to. You can change the $subject line to the one of your choice.

Listing 10-2. A PHP Page for Processing Our Contact Form



CHAPTER 10 ■ FORMS

Thank You



Thank you,

If your message:



""



Requires a response it will be sent to :



Neither of the contact forms–to–e-mail processing scripts have antispam checks. If your web host offers a more robust form processor, such as ASPEmail, you should use it.

ASP.NET 2.0 Form Controls To create an ASP.NET 2.0 form, begin by creating a .aspx page. If you wish to use the default language of C#, you can click the new file button on the standard toolbar and select ASPX, as shown in Figure 10-25.

Figure 10-25. A new ASP page using your Expression Web default language settings

275

276

CHAPTER 10 ■ FORMS

If you wish to change the .aspx page language, you must choose the Page tab and change the language in the Options section at the bottom of the Description column of the dialog box, as shown in Figure 10-26.

Figure 10-26. Change the page language using the drop-down options with ASP.NET as the chosen page category. You can choose which of three supported ASP.NET languages you prefer to use in the Programming Language drop-down. In Exercise 10-2, we will be using VB.NET (VB). The other supported language is Visual JavaScript (VJ#). When you create a .aspx web page, a form control is added by default, since all ASP.NET is processed on the server. A new ASP.NET 2.0 page has more code on it than a simple HTML page, as shown in Figure 10-27.

Figure 10-27. The server-side page language and element are added to all new .aspx web pages.

CHAPTER 10 ■ FORMS

In the Toolbox under ASP.NET, you will find the form controls in the Standard section along with a bunch of other controls not relevant to forms, as shown in Figure 10-28.

Figure 10-28. ASP.NET 2.0 Standard Toolbox controls

With a few exceptions, such as Group Box (fieldset), the form controls you see will be the same as those in the HTML Form Controls. For the most part, the ASP.NET form controls function in the same way as their HTML equivalents, but there are not separate controls for text box and textarea elements. The number of rows and columns you set for a TextBox determine whether the control will display as a text field or as a text-area. None of the ASP.NET form controls have dialog boxes associated with them to set the control properties, because the control attributes are set using the Tag Properties task pane.

277

278

CHAPTER 10 ■ FORMS

Figure 10-29 shows the properties available for an ASP.NET label control. With an ASP.NET label control, the ID is used by scripting, and you associate the label with a form control using the AssociatedControlID property instead of the for attribute. You set the AssociatedControlID attribute using a drop-down menu with the ID of all the ASP.NET controls on your page.

Figure 10-29. ASP.NET Label Control properties.

Exercise 10-2. Creating an ASP.NET 2.0 Contact Form In Exercise 10-1, we created an HTML contact form. In this exercise, we will be creating the same contact form using ASP.NET to create the form and send the form results to you by e-mail. We will begin with a new .aspx web page, but we will not be using the default C#. Instead, we will use VB.NET, since the forms–to–e-mail script we will be using to send results is written in VB.NET and will work with ASP.NET 1, 1.1, and 2.0 to provide compatibility with a wider variety of ASP.NET servers. 1. Begin by selecting New ➤ Page ➤ ASPX, making sure that VB is selected as the Programming Language. 2. Drag, from the ASP.NET Controls Standard section of the toolbox, the following controls using Ctrl+Enter for a line break at the end of each section as shown—do not set the attributes at this time: Label space TextBox Label space TextBox Label space TextBox Button

CHAPTER 10 ■ FORMS

3. Before you create your label text and associate the labels with form controls, name your form fields. With ASP.NET controls, you can easily add required form validation, which will be covered in Chapter 13. For this exercise, select the first TextBox, and give it the ID of txtname. Notice in Figure 10-30 that the first text field is set to SingleLine, which will render in your browser the same as in the HTML text box.

Figure 10- 30. ID is the last of the ASP.NET Contro Propertys in the Tag Properties task pane.

4. Repeat step 2 for the next TextBox, and use txtemail for the ID. For the third TextBox, use txtmessage as the ID, and change the number of rows to 10. ASP.NET controls use width instead of columns to set the width of the text area; set the width to 300px. To finish transforming this TextBox into the equivalent of an HTML text area form field, select the TextMode attribute to trigger the options drop-down menu, and select MultiLine, as shown in Figure 10-31.

279

280

CHAPTER 10 ■ FORMS

Figure 10-31. Change a text box to a text area by selecting MultiLine. 5. Now that your form fields have meaningful IDs assigned, associate each of your label fields with the control to its right, using the AssociatedControlD property. Give each label the ID of lbl[control_name], as shown in Figure 10-32.

Figure 10-32. ASP.NET label properties when associated with a TextBox

CHAPTER 10 ■ FORMS

6. The last ASP.NET control we need to set is the button, which we need to turn into a submit button. Select the button, and from the Tag Properties dialog, match the settings in Figure 10-33, particularly the UseSubmitBehavior property.

Figure 10-33. To turn an asp:button into a submit button, you must set the UseSubmitBehavior to True 7. Save your file, and don’t forget to put in the page title. Your code should now look like this:



ASP.NET form

281

282

CHAPTER 10 ■ FORMS














8. When viewed in a browser, our web page should now look like the one shown in Figure 10-34. Notice that the ASP.NET form is no more attractive than the HTML form when it is not styled.

Figure 10-34. A completed ASP.NET form looks no different in your browser than an HTML form.

CHAPTER 10 ■ FORMS

9. Select View Source in your web browser, and you will see that the ASP.NET controls output HTML to the browser. Compare the following code that your browser receives with the code you see in Expression Web:



ASP.NET form





Name:


Email:


Message:








With the exception of the view state values, the output is standard XHTML. Earlier versions of ASP.NET did not output standards-compliant HTML. Your form is now complete and ready to add processing. Since Expression Web does not have tools for creating form–to–e-mail processing natively, the code you will need to add is not part of this exercise.

283

284

CHAPTER 10 ■ FORMS

Unlike a classic ASP or PHP form, you do not send an ASP.NET form to a separate page for processing. Instead, you have two methods to choose from to send your form results by e-mail. Usually, this is accomplished by a postback condition where the ASP.NET process runs only when the form submits back to itself. You can also send form results using a separately compiled code-behind page created in Visual Studio or Visual Web Developer Express that is specified in an @ Page directive. After this the code, whether it is on the web page or contained in a code-behind page, processes the form results. Code-behind pages are created in Visual Studio or Visual Web Developer Express and are beyond the scope of this book. However, basic form–to–e-mail functionality using ASP.NET code is included in the final ASP.NET page in this chapter. Since we will not be sending the visitor to another page after the form is processed, another label field will be added to the form to display our thank you message. The forms-processing script is compatible with all versions of ASP.NET 1.0, 1.1, and 2.0. If you are using this contact form, you will need to add another label box to your web page. I have added it just above the first line of form fields with the label ID of lblresponse to hold the confirmation message. To keep our form from shifting after the form is submitted I added the following lines: Contact Us.

Please provide the following information: In Chapter 13, we will add validation and error checking to the forms processor.

SENDING E-MAIL FROM YOUR DOMAIN Before you use any form to send e-mail from your website, you must check with your web host. The ASP and PHP form-processing examples will send you the e-mail results as from the person who filled in the form information. Some web hosts will only allow forms hosted on their sites to send with a “from” address that is a valid e-mail address on the domain sending the form. If this is the case, you will need to modify the scripts or use a script provided by your web host.

The following ASP.NET script sends from the webmaster at your domain account and puts the visitor’s name and e-mail in the body of the message. Therefore, you cannot click to reply, but the script will work on most web servers that require your forms to use a local account.





ASP.NET form

Contact Us. Please provide the following information:














285

286

CHAPTER 10 ■ FORMS

When your form is submitted using the submit button, the visitor will see the contents of the lblresponse field on the page. You can add the same style definitions as we used in the HTML form by creating a stylesheet called form.cs, attaching it to form1.html, and dragging the styles to the new stylesheet. Because ASP.NET uses IDs for programming purposes, it is generally better to use classes or contextual selectors to style your ASP.NET controls instead of individual IDs. Associating an ASP.NET form control with a CSS class must be done in the Tag Properties dialog, not by double-clicking the style name as you would with an HTML form element. Once your stylesheet is attached, you can use the CssClass drop-down field to choose the class you wish to apply to the page, as shown in Figure 10-35.

Figure 10-35. Associating a class with an ASP.NET control

Summary In this chapter, you learned how to create a form, what the HTML form elements and their affiliated ASP.NET form controls do, and how to use Expression Web to create a simple contact form using both HTML and ASP.NET. You have been provided with our basic form script, in three languages, as well as instructions for using FrontPage Server Extensions to send the form’s results by e-mail. All forms follow the same principals, and there are many formsprocessing solutions available to you. In Chapter 13, we will add form field validation for our ASP.NET form and notify our visitor if the form is unable to send the e-mail. We will also password protect a section of your website. In Chapter 11, before we move to more ASP.NET when we use Master Pages, we will address some of the usability and legal issues that you need to be aware of as a website designer.

CHAPTER

11

Legal and Usability Issues Y

ou may be wondering why there is a section on legal issues in a book on Expression Web. There are three legal issues that all website creators need to be aware of and one additional legal issue specific to sites created for licensed professionals. These issues are as follows: • Accessibility: The United States, the United Kingdom, Australia, the European Union and its member countries, and many other countries have accessibility laws that apply to websites. Many people consider usability and accessibility to be interchangeable. While that may be true as a general statement, it is possible to create a website that is accessible but not usable. • Copyright: Laws protect your content and determine fair use. • Privacy: The information you collect from your site visitors and what you do with that information needs to be disclosed via a privacy policy on your website. • Licensing: Many professional fields, such as law and medicine, or industries, such as insurance and real estate, may have requirements imposed on their websites by their licensing bodies. First, we will briefly discuss some of the legal issues that you should be aware of when creating a website. Then, we will end with a few simple things you can do to make your site more usable for all your visitors.

Legal Issues The legal issues we will be discussing in this chapter are not unique to the Web. Accessibility is a requirement for buildings, interstate commerce, and most businesses. Copyright applies to all original works. In today’s world of identity theft and fraud, people are concerned about protecting their private data. People who are in licensed professions and regulated industries have compliance requirements in their day-to-day business activities. I bring them up in a book on Expression Web because when you use Expression Web, you are creating a website, which has unique challenges in some of these areas. We will not be covering these areas in detail; I’m just alerting you to areas that you need to consider as you create your website.

287

288

CHAPTER 11 ■ LEGAL AND USABILITY ISSUES

Accessibility Accessibly has been mentioned when we added images and created forms in earlier chapters of this book. I addressed accessibility as each of these elements was introduced, because websites fall under accessibility legislation in most, if not all, English-speaking countries, as well as many non-English-speaking countries (Italy and Spain, for example, have enacted strict accessibility laws). It is much easier to add alt attributes, form labels, and other accessibility features as you create your website than to go back and add them after your website is completed. In the United States, the laws that may apply to your website are Sections 508 and 504 (§508 and §504) of The Rehabilitation Act or the Americans with Disabilities Act (ADA), depending on the type of site you are creating. A layman’s guide to §508 is available at http:// www.webaim.org/standards/508/checklist. Some states have additional accessibility requirements if you are creating sites for government agencies and schools. In the United Kingdom, it is the Disability Discrimination Act that may apply. If you are in another country consult http://www.w3.org/WAI/Policy; the list is not complete, but it is a good place to start. While the statutes may vary slightly from one country to another, most of them parallel the W3C Web Content Accessibility Guidelines (WCAG). Expression Web includes an accessibility checker under Tools ➤ Accessibility Reports, as shown in Figure 11-1.

Figure 11-1. Accessibility Checker options When you run the checker, you can view the results in the Accessibility window; see Figure 11-2.

CHAPTER 11 ■ LEGAL AND USABILITY ISSUES

Figure 11-2. Accessibilty report window The page icon in the bottom-left corner will create the accessibility report as an HTML file (shown in Figure 11-3) that you can use as a checklist when reviewing the pages with errors.

Figure 11-3. An accessiblity report in HTML format

289

290

CHAPTER 11 ■ LEGAL AND USABILITY ISSUES

Whether you use the accessibility report window or generate an HTML page, every WCAG error will include a link to the section of the WCAG for you to be able to check. The line number and page to which the error or warning applies is also provided. Make sure that you check the warnings; in most cases, you will simply need to check that you are using headings appropriately, but all errors and warnings such as missing label fields should be fixed. No automated tool, whether it is Expression Web or an online accessibility checker like Cynthia Says (http://www.contentquality.com/) can guarantee that your website is accessible, which is why following through with the manual checks recommended by the checkers is important.

Copyright From the minute you create your web page and its content, you own the copyright unless you create the work for your employer. In that case, your employer owns the copyright. Despite what most people believe, you do not need to place the copyright symbol or year on your web pages before they are copyrighted. However, if you do not do so, you may have difficulty in proving when your copyright material was created. Registering your copyrighted material is also not necessary, but if a dispute arises registration establishes the date and content of your copyrighted material giving you a better chance of enforcing your copyright. For more information on copyright, visit http://copyright.gov if you are in the United States or http://www.patent.gov.uk/copy.htm if you are in the United Kingdom. My recommendation is to display a copyright notice in the footer of your web page. The one I use on by-expression.com is "© 2007 Cheryl D Wise".

WHY NOT DISABLE RIGHT-CLICK FUNCTIONS? One of the common questions asked by those new to web design is “How do I disable right-click functions?” Many people new to web design think that disabling right-clicking will protect their images and page content from visitors who want to steal their work, but it won’t. Also, you never see them on any professionally created website. Disabling right-click functionality will cost you website visitors, and if yours is an e-commerce site, it can cost you sales. By attempting to disable right-click functions, you are telling your site visitors that you think they are dishonest. There are many legitimate and even highly desirable reasons a visitor might rightclick while visiting your web page. For instance, the visitor may want to add the site to a favorites list, print the page, or open the link in a new window or tab without leaving the current page. Disabling right-clicking requires JavaScript to be enabled in the visitor’s browser and rarely works on web browsers other than Internet Explorer. Turning off JavaScript and refreshing the page will restore rightclick functions. Most no-right-click scripts will also be disabled by antispyware applications and by the simple expedient of using File ➤ Save As or highlighting what the visitor wants to save and copying and pasting the content into a Word document or other file. No-right-click scripts are not effective, and they antagonize visitors. Do not use them. If you have images that you are concerned about, register your copyright, and use the smallest, lowest resolution image that will still be effective. Also, consider putting the image inside of a Flash file or watermarking it to make getting a usable copy more difficult.

CHAPTER 11 ■ LEGAL AND USABILITY ISSUES

Privacy In today’s world, people are concerned about protecting their private information even if only to prevent adding more spam to their inboxes. Visitors want to know what you will be doing with any information you collect about them. Will their contact information be sold? Will you subscribe them to a newsletter if they ask you a question? Just what do you know about your website visitor? Many websites collect anonymous information about the visitor, such as whether they arrived at the site from a search on Google, from another website, or without a referrer, but no uniquely identifiable information is contained in the site’s log file. In other words, the browser and the operating system maybe known, but whether the visitor is Jim Smith who lives at 123 Main Street in Kansas City, Kansas or Jane Doe from 10 Ocean Front Drive in Miami Beach, Florida is not available. If your site falls into this category, then you are not required to have a privacy policy, but it is still best if you have one, even if it is as simple as: We do (do not) maintain log files for this website, but (and) we collect no personally identifiable information. If you collect any identifiable information from your site visitors at all, even if it is by a contact form, you must have a privacy policy on your web site. In some cases, a privacy policy is mandated by statute such as The Data Protection Act in the United Kingdom; the European Commission’s Directive on Data Protection; Canada’s Personal Information Protection and Electronic Documents Act; or in the United States, the Children’s Online Privacy Protection Act, HIPPA, and privacy legislation in individual states such as California. There are two types of privacy policies. The first is human readable and can be as simple as the following: We collect personally identifiable information only when you use our contact form or an e-mail address on this website to contact us. The information contained in your request to us will be used to respond to your communication and will not be maintained after [number of days] from the time of our last correspondence. No information collected will be shared with any third party without your written consent. The second is machine readable, and most modern browsers will check for the presence of a machine readable P3P policy. P3P is a machine-readable privacy policy standard from the W3C (http://www.w3.org/P3P/) that provides a way for your browser to verify that a website has a privacy policy. If the information you are collecting is financial or medical, you should also specify the type of encryption that is being used to protect the data while it is being collected, transmitted, and stored. A machine-readable (XML) privacy policy should be used along with the human-readable HTML version when financial or medical information is collected. Whether you are required to have a privacy policy or not by law, you should have at least a human-readable privacy policy available on your website. My recommendation is to put a link to the HTML version of your privacy policy in the footer of your website next to your copyright information.

291

292

CHAPTER 11 ■ LEGAL AND USABILITY ISSUES

Licensing One often overlooked issue when creating a website is that there may be restrictions on what a website can or cannot contain for regulated professions or industries. For attorneys, certified public accountants, stock brokers, and other professionals, websites may be subject to their regulations on advertising and must comply with their license terms. If you are creating a website for a licensed professional, learn about and get any necessary approvals from the Bar Association, medical board, or other licensing body before you publish the site. Otherwise, you could expose the professional to liability if someone files a complaint against them.

Usability Throughout this book, we have been discussing usability without using the word. In Chapter 1, when we pictured our target visitor, we were taking the first steps towards creating a usable website. Website usability is a specialized area dominated by a few big names: Steve Krug (http://sensible.com), Jared Spool (http://www.uie.com), and Jacob Neilson (http://useit.com). The good news is that you don’t have to be an expert or hire an expert to have a site that is easy to use. Each of these experts has a website that will help you create a usable site. Even if you never visit the website of a single one of these well-known experts, here are a few things you can do to improve the usability of your website. Visitors skim pages; only if they find what they are looking for will they slow down and read the page. This means you must make your site navigation, headers, and links obvious. If your visitor needs instructions on how to use your site, it is too complex. Here are a few usability guidelines for you to follow: • Make the point of your site clear, so the visitor can tell at a glance what the site is about. • Creating a clear visual hierarchy (recall the discussion of structuring your page using headers in Chapter 4) will provide a guide for your visitor. • Group related items into clearly defined sections on the page, and by extension, organize your site in the same way. For example, Amazon color-codes different sections of their website so that visitors know whether they are in books or software. • Make your links visually distinctive: when links look like regular page text visitors don’t know where to click. This is extremely important if you remove the default underlining. • Conventions evolved for a reason. We read from left to right and top to bottom, as a result, newspapers developed conventional layouts with the paper name at the top (masthead) followed by headlines and progressively less important but still interesting stories. While the Web is not print, it has inherited some of the conventions of print layout. It has evolved some conventions of its own that are unique to the Web such as a shopping cart icon for online store baskets. Use conventions—they make your visitor feel comfortable. • Avoid cluttered, busy backgrounds and what Steve Krug calls “happy talk,” that is, introductory and self-promoting hype of the sort that you find yourself tuning out on other sites.

CHAPTER 11 ■ LEGAL AND USABILITY ISSUES

Usability Testing I want to say a brief word about testing your site for usability. After you have worked on your website long enough to have set up a site with navigation, content, and a unique look and feel, you are no longer a good judge of how usable your website is, because you know how things are supposed to work. Before you launch your website, do at least some basic website testing; it isn’t expensive or difficult to do. Ask people to visit your website while you watch and ask them the following questions: • What site is this? • What is the site about? • Where would you find a particular product or page? • What page are you on now? • Is this where you expected to go from the last page you were on? • What are the places you can go from the new page? Repeat this process, asking different people preferably with different skill levels. Remember that your site does not have to be complete to answer most of the questions and getting feedback early, before features are locked in place, is best.

Where Can You Find Testers? Ask friends or family, but only if you can be certain they will not try to spare your feelings and will give you honest answers. I have gotten valuable feedback for the price of a cup of coffee at Starbucks. Be courteous; don’t bother anyone who looks like they are not interested in chatting.

Using Expression Reports Other Expression Web reports that can help you create a usable site are • Hyperlink reports • Site reports

Hyperlink Reports Broken links are a major usability problem. There are two types of hyperlink reports. The first shows you an expanding map of link pages and is accessed from Site ➤ Hyperlinks; see Figure 11-4. You may notice that some of the pages shown in Figure 11-4 have a dim icon for the page and a break in the connecting line. This indicates that there may be a broken link.

■Note You may need to run the Hyperlink report under Site Summary to see the broken link indicators in Hyperlink view.

293

294

CHAPTER 11 ■ LEGAL AND USABILITY ISSUES

Figure 11-4. You can expand the Hyperlink view by double-clicking the plus sign next to each page icon. When you see a dim icon, use the Reports link next to Hyperlinks at the bottom of the window to check your site for broken links. Notice in Figure 11-5 that links to external websites will be checked as well if you are connected to the Internet when you run the hyperlink report.

Figure 11-5. Both internal site links and external links are checked if you are connected to the Internet when you run this report.

CHAPTER 11 ■ LEGAL AND USABILITY ISSUES

Double-click any of the links shown as broken, and you can fix the broken link using Edit Hyperlink, shown in Figure 11-6.

Figure 11-6. You can fix the broken link in more than one page at the same time. Make sure that you fix any links that may have broken before your site goes live.

Site Reports Broken hyperlinks are not the only usability issue that you can spot by using Expression Web’s reports. Other reports allow you to check for slow pages, unlinked pages, and older files. You can also check which pages are attached to Dynamic Web Templates or Master Pages, which will help you manage your site more efficiently. While you can access each of these reports individually from the Site ➤ Reports flyouts, running the Site Summary report, shown in Figure 11-7, gives you a quick overview. From there, you can launch the reports that you find most useful.

Figure 11-7. All the site reports available

295

296

CHAPTER 11 ■ LEGAL AND USABILITY ISSUES

Summary In this chapter, we have looked at some of the legal issues that are associated with creating websites. Next, we followed up on some of those issues using the reporting tools included with Expression Web. You will improve your visitor’s experience if you • Check for accessibility errors, and fix any that are found. • Check for broken links and other site issues. • Visit your pages in Internet Explorer (preferably the latest two versions), Firefox, Opera, and, if possible, with a Mac. If you don’t have a Mac, ask those on a mail list or forum who have Macs to check the site for you and report any problems, or visit a library, Internet café, or someplace else where Macs may be available for public use. • Check your copyright notice. • Make sure you have a privacy policy and a link to it. • Get feedback on appearance and function from people who have not been working on your site. Even feedback from one person is better than no feedback. If you can’t observe people using the site, ask people on mail lists, newsgroups, or forums to test it; people are usually happy to help. Remember that testing for accessibility and usability should be an ongoing process and not something you do once and then forget about; errors can creep in as you edit and add content to your website.

CHAPTER

12

Master Pages M

aster Pages are like Dynamic Web Templates (DWTs) with a couple of major differences. The first difference is that, unlike with DWTs, your web page is not assembled on your local system and uploaded as a single page to your hosting server, so your web server must support ASP.NET 2.0—even web servers that support ASP.NET 1.0 or 1.1 will not attach the Master Page to your content page. Since Master Pages are limited to web servers that support ASP.NET 2.0, why would you want to use a Master Page instead of a DWT? When you change your Master Page, only the Master Page must be uploaded to your web server. Since the page is assembled when requested by the browser instead of in Expression Web before uploading, your publishing time is greatly reduced. This is helpful if you are on a low-bandwidth connection. Another difference between DWTs and Master Pages is that you can nest Master Pages by having a parent Master Page, which contains the primary site navigation, server controls, and other elements that are common throughout the entire site. Your child Master Pages can have section-specific menus, content, and controls that are not in the parent. For example, a section of your website might require the visitor to be logged in to view the content. The parent master would contain the items that are the same in the secure and nonsecure sections of the site, while the child master would provide extra features to manage user accounts and content available only to subscribers. Server control references and URLs are managed by the Master Page, which makes them ideal for situations where you may have two different sets of content delivered depending on the user’s login status. When you create a Master Page, you can lay it out, apply styles, and add ASP.NET controls the same way that you would work with other pages in Expression Web. The layout and content you provide in a Master Page, however, also apply to pages based on the Master Page. In this chapter, we will create a Master Page using the same HTML page from the chapter8.html page that we used to create the DWT in Chapter 9. We will then use that Master Page to create a child master with section navigation. This is the same child master you have seen if you have been downloading the exercise files from http://foundationsofexpressionweb.com/ exercises. You will find the files used in this chapter under the Chapter 12 section in the leftside menu at that URL.

297

298

CHAPTER 12 ■ MASTER PAGES

Creating a Master Page To create a new Master Page, begin by clicking File ➤ New ➤ Page and selecting Master Page from either the General or ASP.NET categories. The page created will be the same no matter which method you choose. If you have a language preference, select it from the Options ➤ Programming Language drop-down; by default, it will be C#. Your new Master Page will be created, though you should make sure when you save the file to keep .master as the file extension. Two ContentPlaceHolder controls will be created in your new Master Page—one in the section and the other in the section as follows: • • The Master Page code is as follows:



Untitled 1





That’s is all there is to creating a new empty Master Page!

■Caution Do not remove the ContentPlaceHolder in the head section. As in the editable region in the head section of a DWT, I recommend adding a default meta element or HTML comment to make sure that the ContentPlaceHolder section does not collapse. Otherwise, you will have to add a page-level style before you can add Page Properties from the right-click menu in Design view.

Expression Web uses the ContentPlaceHolder in the section to include page-level block styles as you work on your pages. If the section’s ContentPlaceHolder is not available, Expression Web creates inline styles instead of classes when you style elements in

CHAPTER 12 ■ MASTER PAGES

content pages, which makes it more difficult to move your content to your external stylesheet. In addition, without the section’s ContentPlaceHolder, you will be unable to add styles; attach an external stylesheet; or set the page description, keywords, or other metatags in content pages through the Page Properties dialog box.

ADDING A PAGE TITLE You may have noticed that the element is outside of the ContentPlaceHolder in the section of the ASP.NET Master Page created by Expression Web, but if you were to preview a page without changing the default page name, you would see “Master Page content” as the page title. This is because the page name is added to the page when it is rendered based on the content of the @page code that is the first line of your Master Page.

You can change the default title from untitled1 to the name of your choice by right-clicking Design view and opening the Page Properties dialog box or by editing the preceding line, whether or not there is a ContentPlaceHolder in the section of your page.

You can add, remove, or modify controls, but you must have at least one ContentPlaceHolder control in the section of your Master Page. Only content and controls inside the ContentPlaceHolder control tags can be edited in pages based on your Master Page. Nothing else in the Master Page is editable in the content pages. In the default Master Page, the section is outside the ContentPlaceHolder, which means you could not edit the page title.

■Tip Make sure your layout elements are outside of the ContentPlaceHolders to ensure your page layout does not break.

Exercise 12-1. Creating Your Master Page In this exercise, you will create a Master Page from an existing HTML page. Then, we will work with ContentPlaceHolder regions in our new Master Page. 1. Begin with the chapter8.html page, or download a copy of the files from http:// foundationsofexpressionweb.com/exercises/chapter12/chapter12.zip. Open the file in Expression Web. 2. Save the page with the name fewd, and choose .master from the type drop-down list, as shown in Figure 12-1.

299

300

CHAPTER 12 ■ MASTER PAGES

Figure 12-1. The “Save as type” is a Master Page (*.master). 3. When you save an existing page as a Master Page, you will get a prompt to tell you that there are no content regions, as shown in Figure 12-2. Click Yes to save anyway.

Figure 12-2. Click Yes to create your new Master Page. 4. A content placeholder will be added to the section when you save your page, as shown in Figure 12-3.

CHAPTER 12 ■ MASTER PAGES

Figure 12-3. A content placeholder will be added to the section once you have saved. 5. You need to add ContentPlaceHolder regions to the section of your new Master Page. To add content place holders on a Master Page in Design view, select the text you wish to be editable in pages created using your fewd.master file, right-click the page, and click Manage Microsoft ASP.NET Content Regions on the context menu, as shown in Figure 12-4.

Figure 12-4. Add content regions by right-clicking in Design view.

301

302

CHAPTER 12 ■ MASTER PAGES

6. This will launch the Manage Content Regions dialog box (see Figure 12-5) that works just like the Manage Editable Regions dialog in DWTs. Type in sidecol for your ContentPlaceHolder name, and click the Add button.

Figure 12-5. Use Manage Content Regions to add, delete, and rename ContentPlaceHolders.

■TIp Use meaningful region names to make it easier for you to manage your site. 7. Repeat steps 5 and 6 to add a ContentPlaceHolder named main in the main_content section. If you right-click an existing control, the Add button is replaced with a Rename button. To rename a ContentPlaceHolder, use the Rename button, but doing so will break pages that are attached to it, which is why you have to confirm any name change, as shown in Figure 12-6. This is why it is good idea to start with meaningful names before you create content pages. To delete the control, use the Remove button.

Figure 12-6. Do not change the name if there are content pages using the Master Page.

CHAPTER 12 ■ MASTER PAGES

After adding a ContentPlaceHolder to the side column and main content areas, the code for your page should look like this:



Chapter 12







Expression Web
The Basics and Beyond

  • home
  • about
  • exercises
  • links
  • contact


left side column Branding



main content area

You don't need to go as high contrast as this to get your branding across.



303

304

CHAPTER 12 ■ MASTER PAGES

Overview

In this exercise we will be creating our website look and feel. Since there is no content to be placed here yet, placeholder, or what is called designer, text will be used after this paragraph.

Created by the Press Release Generator

Thanks to the recent reorganization, the key players are not going to step up to the challenge of competitive killer apps. Having first verified that the drop dead dates give a clear channel towards quality control, a careful examination of the write-offs reveals that the scenarios provide an indication of the established standard application framework.

Task-oriented disclosures make it happen.

As always, the workgroups empower compliant turnkey systems? Having first verified that the goals enable kick-ass graphics, a careful examination of the best systems in the world reveals that revolutionary RISC technology is not the object-oriented headcount readjustments.

More Generated Content

Now that the merger is complete, content sweetening eventually closes the loop on the issue of the team players. This is why Tom Jermoluk recently announced that missions will succeed. The multimedia next generation system gets your input on price-performance technologies. We're going forward on a binary-compatible next generation system.





© 2007 Cheryl D. Wise





■Tip Place your primary site stylesheet outside of the ContentPlaceHolder control in the section so that page-level styles will prevail if there is a conflict.

Your Master Page would appear in Design view as in Figure 12-7.

CHAPTER 12 ■ MASTER PAGES

Figure 12-7. Design view looks much like a DWT would without content, except the content placeholders are outlined in light purple instead of orange.

Your Master Page is ready for you to create pages.

■Caution Before you start creating web pages from your new Master Page, right-click Design view, and select Page Properties. From the Language tab, select the page language. Otherwise, you may find all your text surrounded by or whatever language is your system default.

Exercise 12-2. Creating Content Pages Using Your Master Page While creating a new page from your Master Page is similar to creating a new page from a DWT, adding content to your ContentPlaceHolder requires you to activate the controls. In this exercise, you will create a new page from your Master Page and replace the default content in the placeholders. 1. To create a web page that uses a Master Page, use File ➤ New ➤ Create from Master Page, as shown in Figure 12-8. Name it test.aspx.

305

306

CHAPTER 12 ■ MASTER PAGES

Figure 12-8. Start with Create from Master Page to create content pages. 2. The page created will show your Master Page in Design view, but Code view will look different from anything you have seen to this point, as shown in Figure 12-9.

Figure 12-9. Content pages associated with a Master Page do not show the Master Page’s code. 3. To add content to a ContentPlaceHolder, click inside the placeholder; click the arrow box; and select Create Custom Content, as shown in Figure 12-10.

CHAPTER 12 ■ MASTER PAGES

Figure 12-10. You cannot add content until you have activated Create Custom Content. 4. Clicking Create Custom Content will add an asp:Content region to the page that allows you to add or edit content in the ContentPlaceHolder. As with DWTs, you will get a forbidden symbol when you are over sections of the page that you cannot edit. In Figure 12-11, the ContentPlaceHolder for the side column has been created, and content can now be edited or replaced, but the placeholder for the main content section has not yet been created.

Figure 12-11. One asp:Content control for sidecol has been created.

307

308

CHAPTER 12 ■ MASTER PAGES

5. Create the second asp:Content control for the main section of your page. Save your changes, and preview the page in your browser. Don’t forget to use View Source in your browser, so that you can see how the Master Page and content page were merged before sending the page to your browser.

Nesting Master Pages I mentioned that one advantage of using Master Pages is that you can create child Master Pages by nesting one Master Page inside of another to provide different submenus or other section differences among various parts of your site. In the Exercise 12-3, we will create a nested Master Page with a section menu in the side column and a place for advertisements to a new master created from fewd.master. We will use the text.aspx page created in the first part of this chapter to create our new nested Master Page. Replacing the sidecol content in test.aspx with a menu showing the chapters with exercise files to download will give us a section menu. A smaller section below the new section menu will be added to hold advertisements or other content. The page is shown in Figure 12-12.

Figure 12-12. In Exercise 12-3, we will create this nested master by starting with a page that is attached to an existing Master Page.

CHAPTER 12 ■ MASTER PAGES

Exercise 12-3. Creating a Nested Master Page In this exercise, you will create and apply a child Master Page. 1. Begin this exercise by replacing the content of your sidecol with the following code: Exercise Code

The code used in this book is available for the following chapters:

  • Chapter 3
  • Chapter 4
  • Chapter 5
  • Chapter 6
  • Chapter 7
  • Chapter 8
  • Chapter 9
  • Chapter 10
  • Chapter 12
  • Chapter 13
  • Appendix

 

2. Now that you have the content that will be locked in your new nested Master Page, right-click anywhere in a ContentPlaceHolder region in Design view, and select Manage Microsoft ASP.NET Content Regions, as shown in Figure 12-13.

Figure 12-13. You create a nested Master Page using the right-click option Manage Microsoft ASP.NET Content Regions.

309

310

CHAPTER 12 ■ MASTER PAGES

3. When you choose this option, you will be warned that the current page must be saved as a Master Page before you can manage editable regions, as shown in Figure 12-14. Click Yes to continue.

Figure 12-14. Expression Web warns you before saving as a master. 4. Make sure you save your Master Page with a meaningful name, as shown in Figure 12-15. I suggest using the section name if you will be using the nested master on just one section of your site.

Figure 12-15. Naming the nested master after the name of the section it holds helps you maintain your site. 5. Unlike when the first Master Page was created, no content placeholders are added to your nested Master Page. Expression warns you that there are no ContentPlaceHolder regions in your new master, as shown in Figure 12-16. Save it anyway, since you cannot add a ContentPlaceHolder until the page is saved as a Master Page.

CHAPTER 12 ■ MASTER PAGES

Figure 12-16. You must save the page before you can add ContentPlaceHolders. 6. The Manage Content Regions dialog box will pop up as soon as you save the page. If you add a ContentPlaceHolder at this time, the content placeholder will be placed at the same location as your cursor. Instead, close the dialog box. 7. To wrap a selected area in a new ContentPlaceHolder, select the part of the page where you want to be able to add content, and launch the Manage Microsoft ASP.NET Content Regions from the right-click menu; see Figure 12-13. Add one ContentPlaceHolder to the left menu below the chapter list around the

 

called adverts and one around the entire main content section named mainsub. Save your page once you have added your ContentPlaceHolders. 8. You can now use exercise.master to create pages for the exercise section the same way the text.aspx page was created, by using New ➤ Create from Master Page, as shown in Figure 12-17.

Figure 12-17. Creating a page from a nested master is the same as creating one from any master. Once you have created a web page from your child Master Page, don’t forget to save your new page and then compare it with the text.aspx page you created in Exercise 12-2. Don’t forget to add your asp:Content areas.

Compare the pages in Figure 12-18. On the left is test.aspx, which was created from fewd.master, and on the right is a page named chapter3.aspx, which was created from exercise.master to be the default page for Chapter 3’s downloads. In the text.aspx page, the entire left column is a ContentPlaceHolder. In the chapter3.aspx page’s chapter list, notice the forbidden symbol that indicates the text is outside of the ContentPlaceHolder section of the nested Master Page.

Figure 12-18. The page on the left uses the main master, while the right one uses the nested master.

311

312

CHAPTER 12 ■ MASTER PAGES

To illustrate how updating the primary master (fewd.aspx) will update the nested Master Page (exercise.master) and all pages attached to both Master Pages, I have edited the footer to add links to the site privacy policy and to a site map, as shown in Figure 12-19.

Figure 12-19. Update the fewd.master page by adding new links. There will be no dialog boxes or other prompts to inform you of the change, but when you look at chapter3.aspx, you will see that all the links you added to the fewd.master page are there, as shown in Figure 12-20.

Figure 12-20. Chapter3.aspx immediately reflects the changes to fewd.master. Notice that since chapter3.aspx has not had the default content from exercise.master replaced with custom content, the only code you see is the reference to exercise.master. If we made a change to exercise.master, the changes would only appear on the pages that use exercise.master and not those made directly from fewd.master.

Summary This chapter explored the unique ability to nest Master Pages to create subsections of your page. With Master Pages, you can use ASP.NET controls to add new content and additional ASP.NET controls. As you have seen, Master Pages and DWTs perform similar functions. The primary difference is where the resulting page is created. With DWTs, the page is created inside Expression Web. DWTs depend on the editor for updates, and all changed pages must be uploaded to the web server. Master Pages are editor independent, and updates are effective as soon as the changed Master Page is uploaded. In addition, you can use a nested or child Master Page to independently manage subsections of pages while still enjoying the benefit of a sitewide parent master. For these reasons, if you are hosted on a web server that supports ASP.NET 2.0, Master Pages are a better option for managing your site than DWTs.

CHAPTER

13

Beyond the Basics in CSS and Scripting I

n Chapters 5, 6, and 7, you learned how to use CSS to make your website attractive and easy to maintain with styles. In this chapter, we will look at styling your content for different media. In several places in this book, I have pointed out that you have more control over how pages display when printed than over how they display on the screen. Using a print media stylesheet allows you to specify how a page should print. You can reformat a page so that only the parts of the page you choose are printed and so that you use print measurements, such as margins in inches or centimeters and type in points. In Chapter 10, we created two contact forms. The first was a standard HTML form and the second used ASP.NET. In both cases, the form we created was simple, and the visitor could submit the form without filling in any of the form fields. Having empty forms submitted is usually not desirable. You can prevent form fields from being submitted without content by validating your form before submitting the form for processing. ASP.NET has built-in validation controls, which you can easily use in Expression Web, but these controls are only available if you have ASP.NET on your web server. In this chapter, we will add form field validation to our ASP.NET forms using the built-in validation controls. For those who do not have ASP.NET, simple form–to–e-mail scripts were provided in Chapter 10, and we will add simple JavaScript code to ensure that these HTML forms have content before they are submitted. This chapter will conclude by using ASP.NET to password protect a folder on our website. The Appendix will look at some of the third-party add-ins available for Expression Web.

Alternative Stylesheet Types In this book, we have been creating one stylesheet that will be used whether the visitor is reading the page on a conventional web browser, a pocket PC, a cell phone, a printout, or with some sort of assistive technology such as a screen reader. This is not the only way you can use stylesheets. You can serve a different stylesheet depending on what type of device is being used to access your web page.

313

314

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

By using media stylesheets, you can target specific devices or methods of viewing without having to change the HTML. You can control how a page will be rendered or viewed using the following media types: • all: This is the default type applied to all media if you do not specify a media type. • aural: This media type is intended for use with speech synthesizers or screen readers but is supported by only a few screen readers. See the W3C section on aural stylesheets at http://www.w3.org/TR/REC-CSS2/aural.html for details. • braille: This rarely used media type sends instructions to tactile Braille feedback devices. • embossed: Use this media type for Braille printers. • handheld: For PDAs, some of the new smart phones, and other devices with small screens and limited bandwidth, use this media type. • print: Stylesheets for printing are the best supported media type. This type of stylesheet provides instructions for printers and uses measurements appropriate for printing. More information is available on the W3C paged media section: http://www.w3.org/TR/ REC-CSS2/page.html. • projection: For projected presentations, such as projectors or print to transparencies, use this media type. • screen: This type is best suited for computer screens using a web browser. • tty: For media using a fixed-pitch character grid, such as teletypes, terminals, or portable devices with limited display capabilities, use the tty type. Devices that use the tty media type generally do not support pixels as a unit of measurement. • tv: Use the tv type for television-type devices, such as MSNTV; a game console, such as Xbox or PlayStation; or other devices using low-resolution, limited scroll ability screens, such as traditional CRT televisions. Media type names are case insensitive, but if you are using XHTML, it is case sensitive, so lowercase names is a good practice. Note that not all media types are well supported.

Applying Different Media Types You may write styles for various media in the section by specifying the media attribute in the

Altering the Paragraph Tag for Media

This paragraph should appear blue on the screen with small text and 10px margins.

When viewed on a projector the text would be larger and red with the default browser margins.

For print the page should have 1inch margins and 10pt type with black type.



315

316

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

An alternative method of adding media styles is to use linked stylesheets with the media attribute:

Print Stylesheets A separate style for printing is the most commonly used media stylesheet. Pages generally contain elements that are not necessary when you are printing a page. After all, a menu of hyperlinks does not help when you are viewing a printed page, and decorative images that would waste ink are another item you might prefer not to print. In addition, a printed page using measurements appropriate to print, such as points and margins in inches instead of pixels or ems, may be a better option. In Chapter 9, we created a web page that looks like Figure 13-1 when viewed in a browser.

Figure 13-1. A web page viewed in a browser without a print stylesheet applied. You would think the page shown in Figure 13-1 would print on one page, but as Figure 13-2 shows, without a print stylesheet the web page would equal two printed pages, and since background images do not print, the page is not attractive when printed.

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

Figure 13-2. Without a print stylesheet, the web page prints on two pages and without background images. A single stylesheet can lead to pages that do not print properly. However, if we add a media="print" stylesheet that removes the navigation and makes the content of the side menu full width, the page will print as shown in Figure 13-3, which not only looks better but also fits on one page.

Figure 13-3. The same page with a print stylesheet attached

317

318

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

The stylesheets are attached in the following order:

The styles from the main stylesheet that we will be changing in the print stylesheet are as follows: #masthead h1 { padding: .5em 1em; margin: 0; font-size: 1.5em; } .tagline { font-size: .75em; } #menu { background: url('images/menu-bg.gif') repeat-x bottom #FDB928; height: 45px; } #container { border-right: solid 6px #000000; border-left: solid 6px #000000; padding: 0; margin: 0; background-color: #000000; color: #CEDBAE; } #leftcol { background: #000000 url('images/book-corner.jpg') no-repeat; float: left; width: 150px; padding: 100px 4px 10px 10px; font-size: .88em; } #main_content { padding: .1em 1em; margin: 0 0 0 165px; background-color: #F4F5EF; color: #000000; } #footer { margin: 0px; padding: .1em 1em; font-size: .8em; border: solid 1px #666666; }

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

The new style definitions in our print stylesheet are body { font-size: 12pt; } #masthead h1 { font-size: 20pt; } .tagline { font-size: 14pt; } #menu { width: 0; height: 0; overflow: hidden; } #container { border: none; } #leftcol { width: 100%; padding: 0; font-size: 1em; } #main_content { padding: 0; margin: 0; } #footer { font-size: 9pt; border: none; }

Changes to the Print Layout By changing the menu to have a height and width of 0 with overflow hidden, all browsers will collapse the space, and your menu will not print. Setting the width of the left column to 100 percent takes the content to the full width of the printed pages. The last adjustment to the page layout was to remove the left margin from the maincontent so that it would also print the full width of the page. All of the borders were removed by using border: none for each of the divs where borders were specified in the original stylesheet.

Changes to Text A print font size of 12pt was specified as the default, and the left-side text was reset from .88em, which would be just under 11pt text, to the same size as the main content text. All other font sizes were changed from resizable screen measurements to points as well. The and tagline text were changed from orange to black text to print better on white paper

319

320

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

and avoid wasting color ink. Remember that background colors and images do not print by default. This means you should either use print preview in your browser or actually print the web pages that you believe your visitors may want to print. Examples of pages that are commonly printed are directions, receipts, form confirmation, product pages, and price sheets. You should use print stylesheets whenever you expect your pages to be printed.

Validating your Forms Form validation is used to make sure that your visitor has completed the form fields needed for you to respond to a request or fulfill the purpose of the form and is something many people want to do before a form is submitted. There are two basic types of form validation. The first is client-side validation, which happens before the form is submitted to the form’s processing script. The second happens on the server before the form is processed and sends an e-mail or performs another action. Client-side validation takes place in the visitor’s browser, which makes it very fast and allows you to provide immediate feedback to a visitor who did not fill in required information or formatted the information incorrectly. This method requires JavaScript to be enabled in the visitor’s browser. While the vast majority of web surfers (90 percent is the generally accepted figure as provided by http://www.w3schools.com/browsers/browsers_stats.asp and thecounter.com) do have JavaScript available in their browsers, a significant number of visitors may still submit forms without having the form field contents validated. As a result, many people use both client-side and server-side form validation. ASP.NET provides both by default: it adds JavaScript validation to your forms, but if validation fails there because of a lack of JavaScript support, the form field contents are checked on the server before being submitted for processing.

ASP.NET Form Validation Controls ASP.NET validation controls are found in the Toolbox. To use the validation controls, expand the Validation section of the ASP.NET Controls in the Toolbox task pane, as shown in Figure 13-4.

Figure 13-4. Available ASP.NET validation controls

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

The control you should use depends on what type of validation your form fields need. Available controls are as follows: • CompareValidator control compares the form field entry against a preset value or against the value of another control using less than, equals, or greater than. Common uses of this validator are checking that two e-mail form fields contain the same value or are of a specific data type. • CustomValidator control checks the form field entry against code that you write yourself. • RangeValidator control checks that a visitor’s entry is between a minimum and a maximum pair of numbers, alphabetic characters, or dates. • RegularExpressionValidator control checks that the form field contents match a pattern defined by a regular expression. This allows you to check for predictable sequences of characters, such as those in e-mail addresses, telephone numbers, or zip and postal codes. • RequiredFieldValidator control prevents the form from being submitted when the form fields are empty. • ValidationSummary control does not validate form fields but can be used with the other validation controls to display the error messages from all the validation controls on the page in one block instead of next to the fields being validated.

ASP.NET Validation Controls Tag Properties Before you can use the ASP.NET validation controls, you must have an ASP.NET form with ASP.NET form fields and labels. In this section, I will be using the form.aspx page we created in Chapter 10 with the forms.css stylesheet applied. With each of the ASP.NET validation controls, the values and properties are set in the Tag Properties task pane. There are six sections of properties you can set for each control. They are as follows: • Accessibility, shown in Figure 13-5, allows you to set an access key and tab index for your form fields or validation controls. To avoid conflicts with the user’s settings, do not set either of these properties.

Figure 13-5. ASP.NET validation controls Accessibility properties

321

322

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

• Appearance, shown in Figure 13-6, will be the same on every validation control with the exception of the ValidationSummary control, which will display the ErrorMessage property of the individual validation types. By default, the error messages are red when displayed. You can change the color using the ForeColor property, but if you wish to change the default display, it is best to create a CSS class and apply it to the error message using the CssClass property. For all of the validation controls except ValidationSummary, you must replace the default error message in the ErrorMessage property.

Figure 13-6. Replace the default error message with one appropriate for your form field. • Behavior is where you set properties that differ among the types of validation controls. Later in this section, we will be looking at each of the validation controls individually. However, the following properties in the Behavior section remain constant among the validation controls: • ControlToValidate: Here, you select the control to be validated on each of the validation controls except for the ValidationSummary control. Use the drop-down list to make sure you get the correct field, as shown in Figure 13-7. • Enabled: The default is True. If you change this to False, the control will not function. • EnableTheming: The default is True. This allows you to apply a Visual Studio theme to your site. • EnableViewState: The default is True. Do not change the default if you want to allow the server to keep track of the status of the validation field. • InitialValue: This property is blank and should be left as such.

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

Figure 13-7. All of the form controls available on the page will be available in the drop-down list.

Figure 13-8. Behavior options for Validation Controls

323

324

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

• SetFocusOnError: The default is False. If you set this to True, when the validation routine finds an error, it will take the visitor directly to the error message instead of going to the top of the page. When you use the ValidationSummary control, you should set this property to True. • SkinID: This property allows you to associate the control with a skin or theme ID. As with the EnableTheming property, you can safely leave the defaults alone. Skins and themes are created in Visual Studio. • ToolTip: This sets the title attribute to provide additional information if the visitor mouses over the control. • ValidationGroup: By default, this property is blank. Leave it that way. • Data contains only one property, Expressions, which would be used if you were connecting to a database or other data source to validate against (see Figure 13-9).

Figure 13-9. The only Data option for validation controls is Expressions. • Layout, shown in Figure 13-10, has two properties: Height and Width, which should be contained in a CSS class instead of being set individually for each control.

Figure 13-10. Layout options • Misc has only one property—ID, as shown in Figure 13-11. You should change its name to a more meaningful one than the default, which is the type of validation control. As you add more validation controls of the same type to your page, a number that increments will be added to the default to avoid duplicate names.

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

Figure 13-11. Change the default name for the control ID.

■TIp Decide on a naming convention and stick with it for ease of maintenance.

Individual Validation Control Properties ASP.NET has a variety of validation controls available. You can check if the form field is empty or has content. You can also check if the information is the correct type, such as a date or e-mail address. In addition, you can determine that the content matches either another form field or a static value. Each of the six validation controls are addressed individually in the following sections. RequiredFieldValidator The RequiredFieldValidator does exactly what its name says—it checks for content in the form field before the form is submitted for processing. It does not check the contents of the form field, only whether there is something in the field. Make sure that you provide a meaningful error message, as shown in Figure 13-12.

Figure 13-12. Remember to insert the error message for each validation control.

325

326

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

RegularExpressionValidator A regular expression is a string that describes or matches a set of strings, according to certain syntax rule; it’s similar to using wild cards to match text. Expression Web includes some of the common regular expressions used to validate form information on the Web. Use the RegularExpressionValidator to ensure that any e-mail address submitted using the contact form is in the proper format. In addition to e-mail addresses, you can validate URLs, phone number formats used in various countries, postal or zip codes, and other common form data that follows a regular pattern.

■Note You can only validate the form of the e-mail. You can not use the regular expression validation control to confirm that the address is a real address. The only reliable way to validate a live e-mail address is to send an e-mail and get a response from the e-mail account holder.

To use the ValidationExpression control, click once to bring up the three dots in the ValidationExpression property in the Tag Properties task pane. Click again to launch the Regular Expression Editor shown in Figure 13-13.

Figure 13-13. Many commonly used validation expressions are available from the Regular Expression Editor.

■Tip You can have more than one validation control on a form field. In the case of our simple form, we may want to use the RequiredFieldValidator to make sure that the e-mail field is not empty.

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

Compare Validator The compare validator compares the contents of the form field to either the contents of another field or a value you supply. • To compare one field with another in the same form, select the form field for comparison from ControlToCompare property. • To compare the ControlToValidate field with a value specified in the ValueToCompare property, choose the type of comparison to make from the Operator drop-down as shown in Figure 13-14.

Figure 13-14. Select the two form fields you wish to compare.

Required Range Validator You would use a required range validator to place an upper and lower limit, such as a minimum and maximum order quantity or a date range, as shown in Figure 13-15. In our simple form example, there is no field that would be appropriate for the required range validator.

327

328

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

Figure 13-15. Use a minimum and maximum value for the form field contents.

Validation Summary Up until this point, each of the validation controls we have been adding is displayed where the control is placed on the page. While having the error message next to the form fields tells the visitor which form field was missed or incorrectly filled out, this can lead to problems with page display not only in Expression Web, as shown in Figure 13-16, but also in the browser even before the error messages are displayed, as shown in Figure 13-17.

Figure 13-16. Form with validation in Design view

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

Figure 13-17. The same form displayed in Internet Explorer 7 The gaps you see in Figure 13-17 are where the validation messages take up space but are not displayed until the form is submitted. When the form is submitted, depending on which error message is triggered, the display may look even stranger, as shown in Figure 13-18.

Figure 13-18. When the second validation error message displays, there may be mysterious gaps.

329

330

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

You can prevent this sort of unattractive display by using the validation summary control, the properties of which are shown in Figure 13-19. The summary can be displayed as a list, a bulleted list, or a single paragraph, based on the DisplayMode property. The summary will be displayed on the web page as a bulleted list without changing the defaults.

Figure 13-19. The default provides a bulleted list and an error message where the control is located.

Exercise 13-1. Using ASP.NET Form Validation In Chapter 10, we created a simple form with four ASP.NET form controls. In this exercise, you will add validation for each of the form fields and use the ValidationSummary control to display the error messages. The form code before we begin is as follows:

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

Chapter 13
















The stylesheet referenced in the HTML code for this exercise is the same one created in Chapter 10 and is optional. If you do not use that stylesheet, your form will not be inside the shaded area shown in this exercise’s screen images. Before you begin adding validation controls, you need to add a label and form field for a second e-mail address just below the existing e-mail form field so that you can compare the e-mail address to check for entry errors.




331

332

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

1. Begin by dragging a RequiredFieldValidator control out to the right of each of your form fields, as shown in Figure 13-20.

Figure 13-20. Configure the RequiredFieldValidator properties for the sname field.

2. The properties we need to change for the Name form field are as follows: • ErrorMessage: Name Required: Set the text to display when the control displays. • Display: Dynamic: By changing the display property from static to dynamic, no space will be taken up by the error message unless there is an error. • ControlToValidate: Use the drop-down list to select the sname form field. • ID: RequiredSname: This means you will be able to tell which field the RequiredFieldValidator is validating. 3. Repeat step 2 for the Email, Confirm Email, and Message form fields, except that you should set Display to None on the Message form field. When the Display property is set to None, a ValidationSummary control must be used, which we will add later in this exercise. Make sure that you select the appropriate form field from the ControlToValidate drop-down for every validation control you use. 4. Next, drag out the RegularExpression validator, and drop it to the right of where the Email Required text shows in Design view. Type the ErrorMessage text, set Display to None, and set ID to RegExemail. When we use a ValidationSummary control and place an the asterisk in the Text property, an asterisk will display next to the e-mail form field, and the full message will appear in the summary message box. Next, click the three dots in ValidationExpression property to launch the Regular Expression Editor, and choose Internet e-mail address, as shown in Figure 13-21. Click OK. 5. Now, drag a CompareValidator control to the right of the confirmemail field. Type the ErrorMessage, set Display to None, place an asterisk in the Text property, and set ID to Compemail (see Figure 13-22).

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

Figure 13-21. Expression Web includes the regular expression code for e-mail address validation.

Figure 13-22. Compare e-mail addresses entered in the form. 6. The last validation control we need to add is the ValidationSummary control. Drag it to the top of your form, well above the Name label, before you let go; otherwise, the control tends to land between the Name label and the sname textbox control.

333

334

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

7. While there is no need to change any of the default properties of the ValidationSummary control, you may prefer not to have your error list display bullets if you choose to use an asterisk as the Text property for the e-mail regular expression validation. 8. Save and view your form, which should look like Figure 13-23 in Design view.

Figure 13-23. In Design view, you will see the error message or text properties unless Display is set to None. 9. When viewed in the browser, the form will display the same as it did before ASP.NET validation was added, as shown in Figure 13-24.

Figure 13-24. Error messages appear only after the form is submitted without text or with a malformed e-mail address.

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

10. See what happens when you skip form fields or enter an invalid e-mail address, as shown in Figure 13-22. Try changing the Display properties on the different validation controls to Static and see what difference that makes.

Figure 13-25. Errors appear inline and in the summary area when Display is set to Dynamic.

HTML Forms Validation In the previous section, we used the ASP.NET validation controls. You must have ASP.NET support on your web server to use them on your website. So what do you do if you do not have ASP.NET support on your web server? The options are to • Use JavaScript for client-side validation before the form is submitted. • Use classic ASP, PHP, or some other server-side technology supported by your web server that will check the data before continuing to process the form. • Use a combination of JavaScript on the client side plus server-side scripting. This is how the ASP.NET validation controls work.

335

336

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

In this book, we will limit the non-ASP.NET forms validation to required field validation using client-side JavaScript. In Chapter 10, we created a form named contact; this is the code we will validate:

Name:
Email:
Message:





In the form, we have three fields with the names of sname, email, and message. Simple required field validation can be performed using the following JavaScript code that checks for the presence of any content in each of the form fields specified in the if statements:

For forms with different form field names, in the following code, replace fieldname and Error-Message with the name of the form field you wish to validate and the message you want displayed in the alert box: if (fieldname.value == "") alertMsg += "\nError-Message";

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

Add or remove the if line in the preceding code as necessary for the fields in your form. In order to run this JavaScript script, we must change the element and replace

with

Since these alerts appear in a separate alert box on top of your visitor’s browser window, I recommend adding information to your form to tell the visitor which form fields are required. That way, your visitor is more likely to fill out the required fields before submitting the form. While an asterisk is frequently used to indicate a required field, it is a better practice to spell out “required” next to the form to make it clear.

Password Protecting a Folder The ability to password protect a section of a website is something many web designers wish to do for one or more folders in their websites. In some cases, you can accomplish this by using the control panel provided by your web host, but if you have ASP.NET 2.0 on your web server, you can control access to folders in your site using the web.config file and a login form. Whenever your site visitor tries to access an .aspx page in the folder, they will be directed to a login.aspx page in the main section of your website. If they provide the correct user name and password, the page they requested will be displayed. Only .aspx pages can be protected in this manner; HTML pages can still be viewed. The web.config file is a special XML file that holds information about your website. Depending on your hosting provider, you may already have a web.config file in your website from when your web hosting was set up. If you have an existing web.config file, make a backup copy before you proceed. If you do not have an existing web.config file, you will need to create one. Unlike all of the other code you have been able to download from http:// foundationsofexpressionweb.com, the code for this last section of this chapter is not in the exercise section but in the extras folder. To download the code to password protect a folder on your site, you must go to http://foundationsofexpressionweb.com/extras and log in with the following credentials: • User ID: book • Password: chapter13

Creating a web.config File If you do not have a web.config file, create one by selecting File ➤ New ➤ Page, and from the ASP.NET section, choosing Web Configuration, as shown in Figure 13-26. Save the file created as web.config.

337

338

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

Figure 13-26. Web Configuration creates a web.config file. Expression Web creates a basic web.config file with basic settings and explanatory text surrounded by comments so that your web server does not attempt to execute the code. Without the extra information in the comments, the web.config file created is as follows:







-->

■Tip The section is used if you want to design your own custom page to display when the visitor tries to access a page that does not exist. Simply replace the FileNotFound.htm file with the name of the file you create.

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

To create a protected area, we must replace the default code in the section and add a section so that your section is as follows:













This code changes the method of authentication from Windows operating system to forms based and sets a login expiration time of 30 minutes after the last new passwordprotected page is accessed. says how the password is sent. Here, it is sent as clear text, but if you are protecting really sensitive information, you should use one of the encoded password methods such as SHA1 or MD5. The user name and password specify the login name and password required. You can have more than one user name and password by repeating the line with different values for name and password immediately below the current location, for example:

The section specifies which folder in your website is protected. In this case, it is the extras folder off the root. If you have not done so already, try it out at http:// foundationsofexpressionweb.com/extras.

339

340

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

This is where you will find bonus material for people who own this book. When you attempt to access this section you will be redirected to the login.aspx page. Use the following credentials discussed earlier to confirm it is working: • User ID: book • Password: chapter13

■Note The user name and password are case sensitive, and no spaces are allowed. Make sure you type them correctly as book and chapter13.

If your website has a web.config file provided by your hosting provider, check with your provider before you edit the file to make sure that you do not break any functions or database connections on your site. The completed web.config file should now look like this:















CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace.



-->

Now that we have created a secured area, next we will need to create a login form to allow those with the specified credentials to access the protected folder.

Exercise 13-2. Creating a Login Form In this exercise, we’ll create a login form that looks like the one shown in Figure 13-27. Unlike the contact form we created in Chapter 10, the textboxes in this login form must have the same names as shown in the code at the end of this exercise. The only optional form field is the checkbox that sets a cookie that keeps the visitor logged in.

Figure 13-27. Login form with validation

341

342

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

Follow these steps to create the login form: 1. Start by creating a four-row, three-column table. 2. Drag three ASP.NET label controls into the first column. 3. Drag two ASP.NET textbox controls to the second column with an ASP.NET checkbox in the third row of the second column. 4. The last row contains only an ASP.NET button. 5. The form is finished with an ASP.NET label below the table to hold an error message if the credentials supplied are incorrect. 6. Make a note of the control names in the previous code, and use the Tag Properties task pane to set your control properties to match. 7. With two required field validation controls added for the two textboxes, the complete code for our login form is as follows:



Log In









CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING











 
 

 




When viewed in a browser, we see the simple login form shown in Figure 13-28.

343

344

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

Figure 13-28. A login form that can be styled how you choose.

There remains one small piece of ASP.NET code to add in the section of the page; it checks the login name and password against the ones you specified in the web.config file:

If they match, you will be transferred to the page you tried to access in the protected folder. If not, msg.Text will be displayed on the login form.

Your folder is now password protected, and nothing else is required, since the user’s login will time out after 30 minutes or the time you set in the line in your web.config file.

Summary In this chapter, we have moved beyond the basics of creating a website. The concept of mediaspecific stylesheets was introduced. The ways that print stylesheets can allow you to decide how your web pages will print when your visitor chooses to print was demonstrated.

CHAPTER 13 ■ BEYOND THE BASICS IN CSS AND SCRIPTING

Next, we moved on to validating the fields in our web forms to help you get the information necessary to respond to inquiries from your site visitors. We used ASP.NET 2.0 validation controls, which validate first on the client and again on the server. For situations when ASP.NET 2.0 is not available to us, we used JavaScript for client-side validation of HTML forms. Our last exercise showed how to password protect a section of our website so that only those who know the User ID and password can see the .aspx pages in the folder.

345

APPENDIX

Extending Expression Web with Add-Ons A

ny good web editor must be extensible, because the Web is constantly changing. This capability is one of the strongest assets of Expression Web; it means that third parties can add new features that are easy to use inside of Expression Web. You don’t have to wait for Microsoft to release a new version to get more features. I am talking not about code snippets, like the one we created in Chapter 2, but about features that make it easy to add e-commerce capabilities using PayPal buttons or a shopping cart, improve your search engine ranking using Google Sitemaps, or add Flash banners and interactivity without becoming a programmer or a search engine specialist. Some of these add-ons are commercial applications that charge a fee, and others are created by someone who sees a need and creates a free add-on. At the time of this writing, there were over a dozen add-ons available for download and more actively under development. A current list is available at http://foundationsofexpressionweb.com/exercises/ appendix. Add-ons are usually easy to install and use. Once you have found an extension for Expression Web that offers you the ability to extend what you can do, download the add-on, and follow the extension maker’s instructions on how to install it. Most add-ons will have an installer that creates either a toolbar or an entry in one of the menus.

Adding PayPal Buttons The first add-on I will show you creates a menu item. A free add-on from WEBASSIST creates PayPal buttons to allow people to purchase items, subscriptions, or donate via PayPal. Once you have downloaded and installed this add-on, an entry for PayPal will appear on the Insert menu, as shown in Figure A-1.

347

348

APPENDIX ■ EXTENDING EXPRESSION WEB WITH ADD-ONS

Figure A-1. Some add-ons become part of the Expression Web menus. Once the add-on has been launched from the menu, a series of dialog boxes will walk you through the steps of connecting the buttons you create to a shopping cart and your PayPal account. Provide the requested information at each prompt to create and process the order, as shown in Figure A-2.

Figure A-2. To use this add-on, you simply follow the prompts.

APPENDIX ■ EXTENDING EXPRESSION WEB WITH ADD-ONS

When you have filled in all the information, the add-on will create all the code necessary for your site visitor to purchase the item via PayPal, as shown in Figure A-3.

Figure A-3. All the form fields were created with the values you provided in the dialog boxes. As you can see, it is much easier to create a shopping cart button using an add-on than it is to create each of the hidden form fields one at a time.

Adding Form Tools The next add-on I will show you is Elementz from Instantfx.net; it adds a new toolbar, as shown in A-4, and offers more form tools such as forms processing, form validation, and the ability to create different types of menus.

Figure A-4. Forms add-ons for processing by e-mail and for form validation

349

350

APPENDIX ■ EXTENDING EXPRESSION WEB WITH ADD-ONS

As with the PayPal add-on, a dialog box is launched that allows you to fill in a form to create your server-side processing script, as shown in Figure A-5.

Figure A-5. Fill in the form, and your server-side e-mail script is created by the add-on. Add-ons such as these, which extend the functionality of Expression Web, mean that you can increase your productivity and add features to your website without needing to use external programs such as Flash.

Keyboard Shortcuts Sometimes using a keyboard shortcut rather than your mouse to interact with Expression Web is easier and faster. The standard Windows application shortcuts for copy, cut, paste, and undo work in Expression Web, as they do any other Microsoft program. In this section of the appendix, we’ll discuss keyboard shortcuts that are specific to Expression Web or may behave somewhat differently than you expect. F5 is an example of a keyboard shortcut that may not work as you expect. This is the standard Windows shortcut to refresh the view. In Expression Web, the behavior changes depending on whether your cursor is in the folder list, where it will refresh the list and display files that were added, or in the document window with a web page open. If you use F5 in the document window while also in Design view, the page will revert to the last saved version. If you refresh in Code view, Design view will update to reflect the changes you made to the code. Simply clicking in the Design pane of Split view will do the same thing. Tables A-1 to A-5 show a number of useful Expression Web shortcuts.

APPENDIX ■ EXTENDING EXPRESSION WEB WITH ADD-ONS

Table A-1. Common Windows Standard Shortcuts

Action

Shortcut

Quit Expression Web.

Alt+F4

Cancel an action.

Esc

Undo an action.

Ctrl+Z or Alt+Backspace

Redo or repeat an action.

Ctrl+Y or Shift+Alt+Backspace

Toggle between open dialog boxes.

Alt+F6

Toggle between open dialog boxes in reverse order.

Alt+Shift+F6

Find text or code.

Ctrl+F

Find the next occurrence of the most recent search.

F3

Find the previous occurrence of the most recent search.

Shift+F3

Find the next occurrence of the current selection.

Ctrl+F3

Find the previous occurrence of the current selection.

Ctrl+Shift+F3

Replace text or code.

Ctrl+H

Check the spelling.

F7

Table A-2. Interface and New Page Management

Action

Shortcut

Create a new web page.

Ctrl+N

Open a web page.

Ctrl+O

Close a web page.

Ctrl+F4

Save a web page.

Ctrl+S

Print a web page.

Ctrl+P

Switch between open web pages.

Ctrl+Tab

Switch between open web pages in reverse order.

Ctrl+Shift+Tab

Preview a web page in a web browser.

F12 or Ctrl+Shift+B

Delete a web page or folder in the Folder List task pane or any dialog box.

Delete

Show or hide the Folder List task pane.

Alt+F1

Rename the currently selected file in the Folder List task pane.

F2

Move between Code, Design, and Split views.

Ctrl+Page Down or Ctrl+Page Up

Move between the Code and Design panes in Split view.

Alt+Page Down or Alt+Page Up

Create a hyperlink on a web page.

Ctrl+K

With a graphic selected, create an automatic thumbnail.

Ctrl+T

351

352

APPENDIX ■ EXTENDING EXPRESSION WEB WITH ADD-ONS

Table A-3. Format Shortcuts

Action

Shortcut

Apply bold formatting.

Ctrl+B

Apply an underline.

Ctrl+U

Apply italic formatting.

Ctrl+I

Apply superscript formatting.

Ctrl+plus sign (+)

Apply subscript formatting.

Ctrl+equals sign (=)

Copy text or graphics.

Ctrl+C or Ctrl+Insert

Cut selected text or graphics.

Ctrl+X or Shift+Delete

Paste text or graphics.

Ctrl+V or Shift+Insert

Copy the formatting.

Ctrl+Shift+C

Paste the formatting.

Ctrl+Shift+V

Remove manual formatting.

Ctrl+Shift+Z or Ctrl+spacebar

Center a paragraph.

Ctrl+E

Left-align a paragraph.

Ctrl+L

Right-align a paragraph.

Ctrl+R

Indent a paragraph from the left.

Ctrl+M

Indent a paragraph from the right.

Ctrl+Shift+M

Insert a line break.

Shift+Enter

Insert a nonbreaking space.

Ctrl+Shift+spacebar

Table A-4. Working in Code View

Action

Shortcut

Launch Quick tag editor.

Ctrl+Q

Insert a temporary bookmark.

Ctrl+F2

Move to the next temporary bookmark.

F2

Move to the previous temporary bookmark.

Shift+F2

Go to a line.

Ctrl+G

Insert a code snippet.

Ctrl+Enter

Insert an end tag.

Ctrl+period (.)

Insert a start tag.

Ctrl+comma (,)

Insert an HTML comment.

Ctrl+slash (/)

Complete a word.

Ctrl+spacebar

Select a tag and its contents.

Ctrl+Shift+colon (:)

Find a matching tag.

Ctrl+semicolon (;)

Perform an incremental search.

Ctrl+Alt+F

APPENDIX ■ EXTENDING EXPRESSION WEB WITH ADD-ONS

Table A-5. Working with Tables

Action

Shortcut

Insert a table.

Shift+Ctrl+Alt+T

Select the next table cell’s content.

Tab

Select the preceding table cell’s content.

Shift+Tab

353

Index ■A absolute positioning creating a two-column layout with, 174 layout problems caused by, 183 Access, 12 accessibility Americans with Disabilities Act (ADA), 288 Cynthia Says, 290 Disability Discrimination Act (UK), 288 Expression Web's accessibility checker, 288 Rehabilitation Act, Sections 508 and 504, 288 state requirements for, 288 W3C Web Content Accessibility Guidelines (WCAG), 288 Accessibility Properties dialog box, 211 Accessibility Report, 48 active state, 132 Add Choice dialog box, 260 Add Code Snippet dialog box, 76 additive color model, 128 Adobe PDF files, 97 element, supplying contact information with, 96 Advanced Button control, 259 Advanced Form Properties dialog box, 272 Advanced tab, 81 align property, 139 alpha transparency, 210 Americans with Disabilities Act (ADA), 288 anchor (bookmark), 99 anchor element, 97 AOL, 9 Application Options Configure Editors tab, 51 Open With dialog box, 53 procedure for selecting a graphics editor, 52 Applied Rules section, 194 Apply Styles task pane, 19, 117, 153 color-coded system of dots, 183 renaming styles, 178 using to launch the New Style dialog box, 147 ASP.NET 2.0 adding form validation, 279 AssociatedControlID property, 278, 280

basic form-to-e-mail script, 284 C#, 275 choosing a supported programming language, 276 creating a form in, 275, 278–279, 281–283 creating an .aspx page, 275 form controls, 257 Master Pages and, 297 options for sending form results by e-mail, 284 outputting of standard XHTML, 283 postback, 284 properties available for a Label control, 278 setting control attributes using the Tag Properties task pane, 277 Standard Toolbox controls, 277 styling ASP.NET controls, 286 TextMode attribute, 279 UseSubmitBehavior property, 281 using a separately compiled code-behind page, 284 VB.NET (VB), 276, 278 Visual JavaScript (VJ#), 276 ASPEmail, 275 AssociatedControlID property, 278, 280 AT&T, 9 Attach Dynamic Web Template dialog box, 241 author meta-element, 102 Auto Style Application setting, 61 AutoThumbnail tab, 56

■B backbone servers, 30 Background category, 154 background color, 126 background properties, 129, 154 background-attachment property, 129 background-image property, 129, 155 background-position property, 130, 155 background-repeat property, 129, 155 Behaviors task pane, 44 element, 150 Block category, 151 block element Block category, 151 definition of, in CSS, 151 355

356

■INDEX

element, 96 blogs, 2 element, 62, 65, 84, 122, 154, 235 bookmark (anchor), creating, 99 Bookmark dialog box, 39, 100 Bookmark section, 41 bookmarks, 41 border properties, setting, 158 border style, 61 border-color property, 159 border-style property, 159 border-width property, 159 box model, 163 additive and subtractive models, 163 illustration of, 163 box properties, 139, 163
element, 97 branding a website, 207 brochure websites, 3 Browsed Pages list, 99 browsers box model, 163 changing display defaults, 123 CSS 2.1 support for page layout, 171 default font selection, 72 display quirks of, 31 Firefox, 32, 221 @import statement and older browsers, 119 Internet Explorer, 6, 32, 181, 202 Internet Explorer 6, 210 Internet Explorer 7, 202 lack of kerning in, 152 making a page appear the same in all browsers, 124 Netscape, 33 Opera, 32 passing conditional comments to Internet Explorer, 202 previewing border style in a variety of browsers, 159 Safari, 33 support for CSS stylesheets, 111 translucent PNG images and, 202 understanding display defaults, 122 use of margin vs. padding, 122 BT, 9 business websites, uses and objectives, 2–3 Byte Order Marks (BOMs) addition of, to the top of each page, 56 selecting US/Western European (ISO), 56

■C C#, 275 camel case, 31 element, 169

Cascading Style Sheets. See CSS Cassini web server, ASP.NET 2.0 and, 80 Cell Properties dialog box, 94 cellspacing attribute, 169 CGI Formmail, 272 character set (charset), 83, 101 Checkbox control, 49 Children’s Online Privacy Protection Act, 291 class applying to an element, 121 class attribute, 121 defining, 121 naming conventions, 121 Classic ASP, 80, 273 clear property, 140, 189 code completion, 58 element, 96, 122 Code Formatting tab, 57 Code Snippets tab Add Code Snippet dialog box, 76 Code view and, 75 creating a code snippet, 76 doctypes and code snippets, 76 using code snippets, 41, 77 Code view, 20 auto indent, 55 code completion, 58 default font setting, 57 selection margin, 55 word wrap, 55 Code View section, 40 color additive color model, 128 background, 126 differences in monitor calibration, 149 hex, 128 named, 128 Netscape 4.x and, 128 RGB, 128 text color, 127 understanding color syntax, 127 using a color picker, 156 using the eyedropper to choose a color, 157 using transparency for the absence of color, 128 web-safe, 128 Color Coding tab, 58 color scheme analogous, 208 choosing, 207 complementary, 208 information resources on, 208 monochromatic, 208 primary colors, 208 split complementary (triad), 208

■INDEX

clear property, 140, 189 element, 122 commenting out a portion of a stylesheet, 126 common values for the font-family setting, 73 comparing absolute and relative positioning, 143 contextual selector, 137 creating a font family group, 74 creating an indented block of text, 96 creating effects with overlapping elements, 141 creating horizontal rules, 161 creating styles, 63 CSS 1, 2, and 2.1, 147 .css extension, 62, 112 CSS units of measurement, table of, 131 declaration, 107 defining a CSS class, 121 defining a CSS ID, 121 defining multiple selectors with the same property values, 135 defining page elements, 122 definition of, 107 element, 121 document-level styles, 111–112 embedded stylesheets, 111, 113 external stylesheets, 62, 111 float property, 139 general syntax, 59 grouping background properties together, 130 hex color, 128 element, 161 element, 122 HTML page design before stylesheets, 109 id attribute, 121 @import statement, 112, 119 importing a stylesheet into a web page, 112 inheritance, 119 inline styles, 62, 111–112 keeping presentation elements in one style block, 70 lack of a default size unit in, 132 linking a stylesheet to a web page, 113 links and underlining, 149 margin attribute, 123 named colors, 128 opening and closing curly brackets, 107 padding attribute, 123 passing conditional comments to Internet Explorer, 202 position property, 140 position: absolute, 140

Find it faster at http://superindex.apress.com/

subject matter and, 207 using a color wheel, 208 color temperature, CRTs vs. LCDs, 127 .com TLD extension, 8 comments leaving HTML comments in code, 50 passing conditional comments to Internet Explorer, 202 commercial web hosting, benefits of, 10 Common Language Interface (CLI), 11 Compatibility Checker Report, 49 compression, lossy and lossless, 210 CompuServe, 209 conditional comments, passing to Internet Explorer, 202 Configure Editors tab, 51 Conflicts dialog box, 37 ContentPlaceHolder control, adding to a Master Page, 298 contextual selector, 137 copyright copyright meta-element, 102 displaying a copyright notice, 290 information resources on, 290 ownership of, 290 registering, 290 using the copyright symbol, 290 Create New Document option, 98 creating a masthead, 219 CSS applying the border property to the element, 67 attaching a stylesheet to a web page, 112 background color, 126 background properties, 129 background-attachment property, 129 background-image property, 129 background-position property, 130 background-repeat property, 129 block element, definition of, 151 element, 122 border style, 61 box model, 163 box properties, 139 browsers supporting CSS stylesheets, 111 changing browser display defaults, 123 changing styles for positioning, 68 changing the bullet style of unordered lists, 88 changing the document flow with CSS, 139 changing the number format of ordered lists, 88 changing the order of the cascade, 113 choosing a CSS schema, 147 class attribute, 121

357

358

■INDEX

CSS, continued position: relative, 142 properties accepting multiple values, 125 property, 59, 108 pseudo-classes, 67 resolving CSS style conflicts, 113 RGB color, 128 selectors, 59, 107 separating content from presentation, 91, 109 setting properties and values, 122 element, 121 specificity, 119 specifying a length value, 131 specifying a percentage value, 131 style blocks, 62, 111 stylesheets, advantages of, 108–111 styling multiple selectors, 136 summarizing the cascade order, 120 element, 168 text color, 127 three components of, 59 understanding browser display defaults, 122 understanding color syntax, 127 understanding the cascade, 113, 115–118 using elements to create page sections, 121 using a distinct style for one page section, 120 using a flow layout, 139 using a nonbreaking space, 142 using CSS shorthand, 61 using stylesheets to keep website branding consistent, 230 value, 59, 108 web-safe colors, 128 white-space: nowrap attribute, 153 white-space: pre attribute, 153 writing a custom class for a hyperlink with a pseudo-class, 134 writing styles in the section of a page, 62 .css extension, 62, 112 CSS Properties task pane, 19, 175 Applied Rules section, 163, 194 two sections of, 162 using to write your own CSS, 162 CSS Reports, 49 CSS tab, 59 Auto Style Application setting, 61 using the element as a selector, 67 CSS Tab Styles, changing the setting of, 63 curly brackets, opening and closing, 107 Cynthia Says, 290

■D Data Protection Act (UK), 291 Database tab, 81 declaration, 107 default document name, 29 Default Fonts tab, 56 Define in drop-down box, 149 definition lists, 91 Design view, 20, 28 changing margin and padding in, 165 changing the font displayed in, 57 inserting a line break using Ctrl+Enter, 97 digital certificates, 8 Directive on Data Protection (EC), 291 Disability Discrimination Act (UK), 288 display property, 182 display: inline property, 222 element, 68, 175 definition of, 61 dividing a page into sections, 121, 172 doctitle region, 234, 238–239 doctype, 20, 33 definition of, 83–84 HTML 3.2 or earlier, 84 HTML 4.01 Transitional, 84 XHTML 1.0 Transitional, 84 document tabs, 20 Document window, 20 document-level styles, 111–112 domain forwarding, 9 Domain Name System (DNS), 30 domain names checking the availability of, 6 choosing, 6 .com TLD extension, 8 country codes, 7 country-specific domain extensions, 8 digital certificates and .pro registration, 8 domain forwarding, 9 Global Name Registry, 7 length limitations of, 6 .name TLD extension, 7 .pro TLD extension, 8 registering, 7 registrars, 6, 8 Registry Pro, 8 restricted and unrestricted, 7 second-level domains, 7 subdomains, 7 third-level domains, 7 top-level domains (TLDs), types available, 7 Dreamweaver Web Templates, 233 Drop-Down Box Properties, 260 Dynamic Web Templates (DWTs) adding editable regions, 236, 239 advantages of, 233, 255

■INDEX

■E e-commerce websites, 2 E-mail Address option, 101 Edit Browser List option, 32 Edit Hyperlink dialog box, 241

Edit menu Bookmark dialog box, 39 Bookmark section, 41 changing the margin and padding around an HTML element, 43 Code View section, 40 Hyperlinks section, 41 IntelliSense section, 41 menu items, 39 Quick Tag bar, 44 Quick Tag Editor, 39 Refresh, 44 setting the display mode for the main document window, 42 Styles toolbar, 44 Tag Management section, 40 Visual Aids, options for, 42 editable regions, 233 Editable Regions dialog box, 236, 240 Elementz, 349 tag, 55 em, definition of, 72 embedded stylesheets, 111, 113 Empty Web Site option, 27 error message, 404 (file not found), 30–31 Expression Web Byte Order Marks (BOMs), 56 Cassini web server, 80 choosing a default installation, 13 Code view, 20 default character set, 75 default installation location, 13 Design view, 20, 28 disabling right-click functions, 290 doctype, 20 Document window, 20 Dynamic Web Templates (DWTs), 18 extending through add-ons, 50, 347 FrontPage Server Extensions (FPSE), 12 installing, 13 installing the ASP.NET web server, 15 installing the VBScript editor, 15 IntelliSense, 11 interface features, 16 keyboard shortcuts, 350 Linux-based vs. Windows-based web servers, 11 menu bar, 17 minimum screen resolution recommended, 13 operating systems supported, 13 performing a custom installation, 13 setting the default Code view configuration, 40 setting the default fonts, 56 Split view, 20, 28

Find it faster at http://superindex.apress.com/

applying to a page with content, 247 applying to an existing page, 241 Attach Dynamic Web Template dialog box, 241 attaching to web pages, 241 element, 235 changing an attached DWT, 253 choosing a naming convention for editable regions, 236 comparison to Master Pages, 297, 312 creating, 234 creating a new page from, 243 creating editable regions in the body section, 238 as a design-time tool, 234 detaching a page from, 252 doctitle region, 234, 238–239 dragging and dropping on to an existing page, 243 Dreamweaver Web Templates, 233 Editable Regions dialog box, 236, 240 editing, 251 ensuring consistency between pages, 234 Expression DWTs as working in Dreamweaver, 234 element, 234 headblock region, 240 making global changes to a website, 234 marking page areas as editable regions, 233 element, 239, 250 moving content between editable regions, 249 New Region drop-down menu, 249 null links, 251 preparing an existing page for, 245 preventing editable regions that collapse, 250 removing editable regions, 237 republishing changed pages, 234 retaining page-level styles, 250 saving templates in a Templates folder, 234 selecting Manage Editable Regions to add content regions, 236 server-side scripting and, 242, 248 element, 238, 250 updating pages attached to, 251 uploading not required, 234 using locked areas, 233

359

360

■INDEX

Expression Web, continued Status bar, 22 synchronizing a website, 36 task panes, 18 Undo option, 33 using a third-party FTP program, 34 using an external graphics editor, 51 using the built-in FTP client, 34 UTF-8 encoding, 56, 75 Visual Aids, 22 Web Site view, 20 Windows Vista, 13 Windows XP, Service Pack 2, 13 external stylesheets, 111 attaching using a relative link, 62 detaching before removing Unused Styles, 49 importing, 63

■F File menu Edit Browser List option, 32 menu items, 25 New option, 26 New Page option, 26 New Web Site option, 26 Preview in Browser option, 26, 31 Publish option, 26, 33 file names, using lowercase letters and hyphens in, 30 File Transfer Protocol (FTP), 9, 33 Login Credentials dialog box, 35 using to publish a website, 35 File Upload Properties dialog box, 262 Firefox, 32, 221 fixed-width layout, 203 float property, 139 effect of the clear property on, 190 image alignment and, 212 replacing the HTML align attribute, 185 using instead of the position: absolute property, 185 flow layout, definition of, 139 fluid layout, 203 Folder List, displaying local site files, 18–19 Folders item, 78 element, as deprecated, 85 Font Families tab, 70 tag, cleaning up in imported files, 49 fonts Arial, 73 Courier and Courier New, 74 creating a font family group, 74 default selection for browsers, 72 em, definition of, 72 font-family definition, 108

Georgia, 73 guidelines for using, 74 handling multiple-word font names, 74 Helvetica, 73 including a font not installed on your computer, 75 including a generic font family in a font value list, 74 lack of kerning in browsers, 152 listing multiple font choices for visitors, 74 monospace and monotype, 72 Tahoma, 73 three major families of web fonts, 72 Times New Roman, 72 using serif fonts at small sizes, 72 Verdana, 73 element, 257, 271 Form Field Properties dialog box, 258, 266 form handler, definition of, 270 Form Properties dialog box, 262, 270 form-processing bots, 271 Format menu automatic reuse of existing styles, 46 Dynamic Web Template option, 46 Font drop-down, 70 Master Page option, 46 menu items, 45 Remove Formatting option, 45 Format toolbar, 68 autogenerated styles and autoincrement, 148 creating styles, 17, 63, 147 forms Add Choice dialog box, 260 adding hidden field name and value pairs, 262 Advanced Button control, 259 Advanced Form Properties dialog box, 272 ASP.NET 2.0 form controls, 257 ASPEmail, 275 associating a label with a form field, 259 basic form-to-e-mail script using ASP.NET code, 284 CGI Formmail, 272 checking with a web host regarding e-mail forms, 284 Classic ASP page for processing a contact form, 273 creating a fieldset, 260 creating a simple contact form, 266 creating an .aspx page, 275 creating an ASP.NET 2.0 form, 275, 278–279, 281–283 dragging elements from the Toolbox, 257 Drop-Down Box Properties, 260

■INDEX

FrontPage, importing content from, 49 FrontPage Server Extensions (FPSE), 12, 33 processing a web form with, 270, 272 publishing using HTTP, 36 remembering the user ID/password when publishing a site, 35 Remote Web site location field, 35 using to publish a website, 35

■G gamma of monitors, 127 gateway computers, 30 General tab, 54, 79 General Tools section, 48 GeoCities, 9 GIF (Graphics Interchange Format), 209 Global Name Registry, 7 Google, 102 AdWords, 234 Checkout, 2 Sitemaps, 347 Group Box Properties dialog box, 260

■H tag, 85 hand cursor, 201 element, 66, 84, 112, 234 headblock region, 240 header markup, 85 hex color, 128 HIPPA, 291 horizontal rules, creating, 161 hover state, 132 element, 161 href attribute, 97 HTML element, 96 align property, 139 alternate language page, 105 anchor (bookmark), 99 anchor element, 97 attaching a stylesheet to a web page, 112 automatic highlighting of invalid or incompatible HTML, 55 background color, 126 background properties, 129 background-attachment property, 129 background-image property, 129 background-position property, 130 background-repeat property, 129 element, 150 element, 96 element, 62, 84, 122 box properties, 139
element, 97 browsers supporting CSS stylesheets, 111

Find it faster at http://superindex.apress.com/

File Upload Properties dialog box, 262 element, 257, 271 form field, 257 Form Field Properties dialog box, 258, 266 form handler, definition of, 270 Form Properties dialog box, 262, 270 form-processing bots, 271 forms-processing scripts, 273 Group Box control, 260 Group Box Properties dialog box, 260 hosting on a Linux server, 274 hosting on a Windows 2000/Windows 2003 server, 273 HTML element, 257 Input (Button) control, 259, 261 Input (Checkbox) control, 261 Input (File) control, 262 Input (Hidden) control, 262 Input (Image) control, 263 Input (Password) control, 264 Input (Radio) control, 264 Input (Reset) control, 264 Input (Submit) control, 264 Input (Text) control, 264 Label control, 265 element, 259 element, 260 naming convention for form fields, 258 Option Button Properties dialog box, 264 password text box, 264 PHP page for processing a contact form, 274 PHP Send Mail, 274 Picture Properties dialog box, 263 postback, 257 processing, 270 Programming Language drop-down menu, 276 Push Button Properties dialog box, 261 required elements, 257 reserved words for field names, 258 sendfile.php, 274 sending form results by e-mail, 271 sendmail.asp, 273 sendmail.php, 274 styling ASP.NET controls, 286 submit button, 257 Tag Properties dialog box, 286 Text Area control, 265 TextArea Box Properties dialog box, 268 Toolbox, Form Controls section, 257 using ASP.NET 2.0 to add form validation, 279 using FPSE to process a web form, 270, 272 Windows server support for CDONTs, 273

361

362

■INDEX

HTML, continued element, 169 cell padding and cell spacing, 168 cellspacing attribute, 169 changing browser display defaults, 123 changing the document flow with CSS, 139 changing the margin and padding around an element, 43 character set (charset), 83, 101 class attribute, 121 clear property, 140, 189 element, 96, 122 commenting out a portion of a stylesheet, 126 comparing absolute and relative positioning, 143 contextual selector, 137 creating a list, 89 creating an indented block of text, 96 creating effects with overlapping elements, 141 creating headers for a website, 86 creating hyperlinks, 97 creating ordered, structured pages, 83 CSS 1, 2, and 2.1, 147 CSS properties accepting multiple values, 125 CSS styles and the section of a page, 62 CSS units of measurement, table of, 131 declaration, 107 defining a CSS class, 121 defining a CSS ID, 121 defining multiple selectors with the same property values, 135 defining page elements, 122 definition lists, 91 element, 121 document-level styles, 111–112 embedded stylesheets, 111, 113 external stylesheets, 111 float property, 139 element, as deprecated, 85 element, 257 grouping background properties together, 130 tag, 85 element, 84, 112 header markup, 85 hex color, 128 href attribute, 97 element, 83–84, 122 hyperlinks, 97 id attribute, 121 element, Mosaic’s introduction of, 208

@import statement, 112, 119 importing a stylesheet into a web page, 112 inheritance, 119 inline styles, 111–112 element, 259 language, 102 element, 260 element, 105 linking a stylesheet to a web page, 113 lists, types of, 88 making relevant headers, 86 margin attribute, 123 meta-elements, 101 named colors, 128 Netscape 4.x, 113 element, 105–106 opening and closing curly brackets, 107 Optimize HTML dialog box, 49 ordered lists, 88

element, 84 padding attribute, 123 page design before stylesheets, 109 position property, 140 position: absolute, 140 position: relative, 142 element, 96 property, 108 reserved words for form field names, 258 resolving CSS style conflicts, 113 RGB color, 128 element, 105 search engines and properly structured sites, 86 selector, 107 setting properties and values, 122 element, 121 specificity, 119 specifying a length value, 131 specifying a percentage value, 131 style blocks, 111–112 element, 105, 111–112 stylesheets, advantages of, 108–111 styling multiple selectors, 136 tables, 91 text color, 127 element, 78, 99, 101

    element, 196 understanding browser display defaults, 122 understanding color syntax, 127 understanding how to use structural markup, 86 unordered lists, 88 using elements to create page sections, 121

    ■INDEX

    ■I ID applying to an element, 121 defining, 121 id attribute, 121 naming conventions, 121 element, Mosaic’s introduction of, 208 images Accessibility Properties dialog box, 211 alpha transparency, 210 alternative text, 210–211 browser support for translucent PNG images, 202 clip art, disadvantages of, 209 copyright considerations, 209 creating a masthead, 219 float property and image alignment, 212 GIF (Graphics Interchange Format), 209

    height and width, 210 index transparency, 209 investing in a graphics editor, 208 JPG/JPEG (Joint Photographic Experts), 209 location, 210 lossy and lossless compression, 210 Netscape 4, 210 overcompression and artifacts, 210 photos, tips for using, 209 PNG (Portable Network Graphics), 161, 210 recommended image formats for websites, 209 relating images to a site’s content and goals, 208 requirements for inserting on web pages, 210 stock photos, 209 translucent effects, 210 using an empty alt attribute, 223 using original graphics, 209 Web Image Formats filter, 213 iMail, 11 @import statement, 112, 119 index transparency, 209 index.html, 29 information websites, 2 inheritance, 119 inline styles, 62, 111–112 effects of using, 65 using sparingly, 118 Input (Button) control, 259, 261 Input (Checkbox) control, 261 Input (File) control, 262 Input (Hidden) control, 262 Input (Image) control, 263 Input (Password) control, 264 Input (Radio) control, 264 Input (Reset) control, 264 Input (Submit) control, 264 Input (Text) control, 264 Insert Hyperlink dialog box, 98, 196 Insert menu, items in, 44 Insert Table dialog box, 167 Insert Table menu, 167 Instantfx.net, 349 IntelliSense, 11, 41 IntelliSense tab, support for ASP.NET 2.0, 58 Internet Explorer, 32 display bug, 181 length limitations on domain names, 6 passing conditional comments to, 202 using a different background from other web browsers, 202 Internet Explorer 6, 210

    Find it faster at http://superindex.apress.com/

    using a distinct style for one page section, 120 using a flow layout, 139 using a nonbreaking space, 142 using an e-mail hyperlink, 101 value, 108 web-safe colors, 128 whitespace, removing in code, 50 http-equiv browser instructions character set (charset), 101 language, 102 Hyperlink Properties dialog box, 224 Hyperlink reports, 293 Hyperlink view, 294 hyperlinks adding an underline to a moused-over link, 133 anchor element, 97 changing a hyperlink from inline to block, 199 creating, 97 creating a hyperlink to a new page, 224 distinguishing a link from ordinary text, 132 four pseudo-classes for indicating link state, 132 href attribute, 97 Hyperlink Properties dialog box, 224 Insert Hyperlink dialog box, 98 showing a hand cursor for a mouseover action, 201 types of, 97 writing a custom class for a hyperlink with a pseudo-class, 134 Hyperlinks item, 79 Hyperlinks section, 41

    363

    364

    ■INDEX

    Internet Explorer 7 fixes for CSS rendering bugs, 202 support for PNG image format, 202 Internet Protocol (IP) address, 6 Internet Service Provider (ISP), website hosting, 9

    ■J JavaScript, using for client-side scripts, 106 JPG/JPEG (Joint Photographic Experts), 209 Juicy Studio, 127

    ■K keyboard shortcuts Code view shortcuts, table of, 352 format shortcuts, table of, 352 interface and new page management shortcuts, table of, 351 standard Windows shortcuts, table of, 350 table shortcuts, 353 Krug, Steve, 292

    ■L Label control, 265 element, 259 language, http-equiv browser instructions, 102 Language tab, setting to US/Western European (ISO), 81 Layout category clear property, 185 clip property, 185 cursor property, 185 differences between hidden and collapse, 184 display property, 184 float property, 185 overflow property, 185 providing scroll bars, 185 visibility property, 184 Layout Tables task pane, 169 legal issues accessibility checker in Expression Web, 288 accessibility laws applying to websites, 287–288 Americans with Disabilities Act (ADA), 288 Children’s Online Privacy Protection Act, 291 copyright laws, 287, 290 Cynthia Says, 290 Data Protection Act (UK), 291 Directive on Data Protection (EC), 291 Disability Discrimination Act (UK), 288 disabling right-click functions, 290 HIPPA, 291

    human- and machine-readable privacy policies, 291 licensing requirements, 287, 292 P3P policy, 291 Personal Information Protection and Electronic Documents Act (Canada), 291 privacy policies, 287, 291 Rehabilitation Act, Sections 508 and 504, 288 state requirements for accessibility, 288 W3C Web Content Accessibility Guidelines (WCAG), 288 element, 260 letter-space, 153 licensing, 287, 292 element, types of link relationships, 105 link state, 132 Linux (Unix) servers case sensitivity of, 30 encoding a space as %20, 30 List category, 192 lists changing a bullet style using CSS, 88 changing a number format using CSS, 88 creating, 89 creating a list as a menu using contextual selectors, 192 definition of, 91 ordered, 88 term and definition parts, 91 types of, 88 unordered, 88 using for site navigation, 192 local website changing the folder location of, 27 choosing a screen resolution for previewing, 32 choosing between .htm and .html extensions, 30 creating, 25–27 creating a new web page, 28 default document name, 29 index.html, 29 managing relative file paths, 26 necessity for, 26 options for publishing a site, 34 Page Properties dialog box, 28 procedure for publishing, 37 synchronizing a website, 36 testing in a real web browser, 31 transferring local web pages to a production server, 34 using F12 to preview, 33 using meaningful file and folder names, 30 Lorem Ipsum text, obtaining online, 217

    ■INDEX

    ■M

    meta-elements adding with the Page Properties dialog box, 102 author, 102 copyright, 102 description, 102 http-equiv browser instructions, 101 keywords, 102 robot, 102 Microsoft Access, 12 Excel, 93 Office 2007, 13 Paint, 51 Script Editor, 50 SQL Server, 12 Windows Vista, 13 Windows XP, Service Pack 2, 13 Word, 45 Modify Style dialog box, 154, 200 border-color property, 159 border-style property, 159 border-width property, 159 Box category, 163 Layout category, 184 Position category, 174 setting border properties, 158 setting box properties, 163 Modify Styles task pane, 153 Mono Project, website of, 11 Mosaic, 208 MSN Live Search, 102 mystery-meat navigation, 207

    ■N .name TLD extension, 7 named colors, 128 naming conventions camel case, 31 file and folder names, 31 naming style sheets, 31 Neilson, Jacob, 292 Netscape 4.x, 113, 128, 210 New option, 26 New Page option, 26 New Region drop-down menu, 249 New Style dialog box, 179, 196, 201 Background category, 154 background-image, 155 background-position, 155 background-repeat, 155 Block category, 151 Box category, 163 color drop-down list, 149 Define in drop-down box, 149 Description section, 150

    Find it faster at http://superindex.apress.com/

    Macintosh, Safari browser, 33 Manage Content Regions dialog box, 302, 311 Manage Editable Regions, 236 Manage Microsoft ASP.NET Content Regions, 301, 309 Manage Styles task pane, 19, 158, 230 color-coded system of dots, 183 renaming styles, 178 using to launch the New Style dialog box, 147 margin, changing in Design view, 165 margin attribute, 123 Margins and Padding Visual Aids, enabling, 165 Master Pages adding, deleting, and renaming ContentPlaceHolders, 298, 302 adding, removing, and modifying controls, 299 basing content delivery on the user’s login status, 297 changing the default page title, 299 comparison to DWTs, 297, 312 creating a nested Master Page, 308–311 creating a new Master Page, 298 creating content pages using a Master Page, 305–306, 308 creating from an existing HTML page, 299–300, 302–305 having parent and child masters, 297, 308 keeping .master as the file extension, 298 Manage Content Regions dialog box, 302, 311 managing server control references and URLs, 297 Master Page option, 46 placing the primary site stylesheet, 304 selecting Manage Microsoft ASP.NET Content Regions, 301, 309 selecting the Create from Master Page menu option, 305 selecting the page language, 305 updating the primary and secondary masters, 312 using View Source in your browser, 308 web server support for ASP.NET 2.0 required, 297 menu bar, 17 menus, 207 adding mouseover behavior, 223 turning an unordered list into a horizontal menu, 222 element, 239, 250 tag, 77

    365

    366

    ■INDEX

    New Style dialog box, continued Font category, 148 font-family drop-down list, 149 font-variant drop-down list, 149 inline elements, 152–153 launching, 148 Layout category, 184 letter-space, 153 More Colors option, 156 Preview section, 150, 156 selecting a font category, 150 Selector box, 148 Selector drop-down list, 156, 168 setting background properties, 154 setting box properties, 163 Table category, 168 text-align, 152 text-indent, 153 text-transform drop-down list, 149 vertical-align, 152 white-space, 153 word-space, 153 New Table dialog box, available style options, 168 New Web Site option, 26 no-right-click scripts, 290 nonbreaking space, 142, 169, 250 element offering alternative navigation with, 106 using meaningfully, 106 null links, 251

    ■O Open With dialog box, 53 Opera, 32 Optimize HTML dialog box options not recommended for use, 50 Remove Comments section, 50 Remove Whitespace section, 50 using, 49 Option Button Properties dialog box, 264 Orange, 9 ordered lists, 88 Outlook, 11

    ■P

    element, 84 P3P policy, 291 padding, 43 changing in Design view, 165 padding attribute, 123 Page Editor Options, 40, 74, 120, 214 AutoThumbnail tab, 56 Code Formatting tab, 57 Color Coding tab, 58 CSS tab, 59

    Default Fonts tab, 56 dialog box, 147 document-level styles, 111 Font Families tab, 70 General tab, 54 IntelliSense tab, 58 Picture tab, 56 Ruler and Grid tab, 56 page layout adding a two-column layout, code example, 226 creating a centered, fixed-width layout, 204 creating a hyperlink to a new page, 224 creating a masthead, 219 creating a two-column layout using absolute positioning, 174 CSS 2.1 support for, in current browsers, 171 establishing a distinctive look and feel, 217 fixed-width layout, definition of, 203 fluid layout, definition of, 203 layout problems caused by absolute positioning, 183 positioning copyright information, 189 restricting the width of a page, 204 starting with the basic page-level defaults, 218 turning an unordered list into a horizontal menu, 222 two common types of, 171 using elements to divide a page into sections, 172 using stylesheets to keep website branding consistent, 230 Page Properties dialog box, 28, 68, 239, 299 Custom tab, 102 General tab, 102–103 Paint.NET, downloading, 51 Paragraph dialog box, 68 password text box, 264 PayPal buttons, adding, 347 PDF files, 97 Personal Information Protection and Electronic Documents Act (Canada), 291 personal websites, uses and objectives, 2 PHP, 80 PHP Send Mail, 274 Picture dialog box, 213 Picture File Types dialog box, 56 Picture Properties dialog box, 263 Picture tab, 56 Pictures toolbar, 212 placeholder text, 217 PNG (Portable Network Graphics), 161, 202, 210

    ■INDEX

    ■Q Quick Link bar, 65 Quick Tag bar, 20, 44, 68, 87, 119, 175, 247 Quick Tag Editor, 39, 266–267

    ■R Recalculate Hyperlinks item, 79 Reformat HTML option, restoring text indenting, 50 Refresh, 44 registrars, 6, 8 Registry Pro, 8 Rehabilitation Act, layman's guide to, 288 Remote Web Site item, 79 Remote Web Site Properties dialog box, 34 Remove Formatting option, 45 Remove Generated HTML section, 49 Remove Unused Content section, 49 Reports item, 79 Reports section, 48 RGB color, 128 Road Runner, 9 robot meta-element, 102 Ruler and Grid tab, 56

    ■S Safari, 33 screen readers, 211 element, 105 scripting folders, 38 scroll bars, providing, 185 search engine optimization (SEO), 102–103 Search Engine Watch, 102 search engines description meta-element, 102 Google, 102 ISP-provided sites and, 9 keywords meta-element, 102 MSN Live Search, 102 page description and, 29 properly structured sites and, 86 search engine optimization (SEO), 102–103 Search Engine Watch, 102 Yahoo!, 102 second-level domains, 7 Section 508 accessibility, 48 Secure Socket Layer (SSL), 10 selectors, 107 class, 60 HTML element, 60 ID, 60 sendfile.php, 274 sendmail.asp, 273 sendmail.php, 274

    Find it faster at http://superindex.apress.com/

    POP3 mail services, 11 Position category absolute option, 174 creating a two-column layout using absolute positioning, 174 fixed option, 174 relative option, 174 position property, 140 position: absolute, 140 position: relative, 142 postback, 257, 284 element, 96 Preferences section, 51 Preview in Browser option, 26, 31 Preview Tab, 80 privacy policies, 287 advisability of having, 291 Children’s Online Privacy Protection Act, 291 collecting anonymous information about site visitors, 291 Data Protection Act (UK), 291 Directive on Data Protection (EC), 291 HIPPA, 291 human- and machine-readable versions, 291 P3P policy, 291 Personal Information Protection and Electronic Documents Act (Canada), 291 specifying the data encryption type used, 291 types of, 291 .pro TLD extension, 8 Program Management section, 50 Programming Language drop-down menu, 276, 298 Properties Summary tab, 79 property, 59, 108 pseudo-classes active state, 132 adding an underline to a moused-over link, 133 hover state, 132 inheritance from the element, 132 link state, 132 listed order of, 67, 132 visited state, 132 Publish option File Transfer Protocol (FTP), 33 FrontPage Server Extensions (FPSE), 33 Remote Web Site Properties dialog box, 34 synchronizing a website, 36 web host’s preinstalled files/folders, 36 Push Button Properties dialog box, 261

    367

    368

    ■INDEX

    server-side scripting, 9 Set Language option, 48 site map, 4, 106 Site menu Advanced tab, 81 Database tab, 81 Folders item, 78 General tab, 79 Hyperlinks item, 79 Language tab, 81 links and disabling metafiles, 79 Preview Tab, 80 Properties Summary tab, 79 Recalculate Hyperlinks item, 79 Remote Web Site item, 79 Reports item, 79 Site Settings item, 79 Web Site tab, 78 site navigation, 207 Site Settings item, 79 Site Settings Language tab, 55 Site Summary reports, 295 SMTP mail services, 11 element, 121 definition of, 61 specificity, 119 spell-checker, 48 spelling options, 55 Split view, 20, 28 Spool, Jared, 292 SQL Server, 12 Status bar, 22 tag, 55 structural.html, downloading, 147 style block, 62, 112 element, 105, 111–112 styles, creating, 63 Styles toolbar, 44 creating new styles with, 147 stylesheets advantages of, 108–111 attaching to web pages, 112 .css extension, 112 embedded, 111, 113 importing into a web page, 112 linking to a web page, 113 subdomains, 7, 9 submit button, 257

    ■T

element, 168 Table Properties dialog box, 168 tables adding a nonbreaking space to table cells, 169 adding comment tags, 169

element, 169 captions, 91 Cell Properties dialog box, 94 changing the vertical alignment in table cells, 169 column and row headers, 91 creating, 92, 167 designers’ abuses of, 91, 110 Insert Table menu, 167 Layout Tables task pane, 169 not using tables for page layout, 170
element, 168 Table Properties dialog box, available style options, 168 turning a data cell into a header cell, 94 using for data presentation, 91 Tag Management section, 40 Tag Properties dialog box, 286 Tag Properties task pane, 19, 162, 266, 277 task panes Apply Styles, 19 CSS Properties, 19 Folder List, 19 Manage Styles, 19 Tag Properties, 19 Toolbox, 19 templates Dreamweaver Web Templates, 233 Dynamic Web Templates (DWTs), 233 purpose of, 233 saving templates in a Templates folder, 234 server-side templates, 233 types of, 233 Text Area control, 265 text color, 127 text-align, 152 text-indent, 153 TextArea Box Properties dialog box, 268 TextMode attribute, 279 third-level domains, 7 title attribute, 149 element, 78, 99, 101, 238, 250 Toolbox task pane, 19, 44. 257 Tools menu Accessibility Report, 48 Application Options, 51 changing the language of a section of text, 48 Checkbox control, 49 Compatibility Checker Report, 49 CSS Reports, 49 General Tools section, 48 Optimize HTML dialog box, 49 Page Editor Options, 40, 54 Preferences section, 51

■INDEX

Program Management section, 50 Remove Generated HTML section, 49 Remove Unused Content section, 49 Reports section, 48 running the spell-checker and setting spelling options, 48 Set Language option, 48 top-level domains (TLDs), types available, 7 Tripod, 9

■U

■V value, 59, 108 VB.NET (VB), 276, 278 vertical-align, 152 View menu, items in, 42 Virtual PC downloading from Microsoft, 33 running with a second operating system, 33 VisiBone, 127 visited state, 132 Visual Aids, 22 Margins and Padding Visual Aids, enabling, 165 options for, 42 Visual Basic Editor, 50 Visual JavaScript (VJ#), 276 Visual Studio, 284 Visual Web Developer Express, 284

■W W3C validator, 49 W3C Web Content Accessibility Guidelines (WCAG), 127, 288 watermarks, 130

Find it faster at http://superindex.apress.com/

    element, 196 Undo option, 33 unordered lists, 88 upload managers, 9 usability creating a clear visual hierarchy, 292 guidelines for, 292 Hyperlink reports, 293 Krug, Steve, 292 making links visually distinctive, 292 Neilson, Jacob, 292 Site Summary reports, 295 Spool, Jared, 292 testing a website for usability, 293 using website conventions, 292 user variables, definition of, 104 UseSubmitBehavior property, 281 UTF-8 encoding, 56, 75 UTF-16 encoding, 56

    Web Accessibility Initiative (WAI), 48 web hosting ASP.NET 2.0, 11 checking for the supported database and server-side tools, 12 commercial web hosting, 10 domain forwarding, 9 File Transfer Protocol (FTP), 9 hosting using a subdomain name, 9 ISP hosting, 9 Linux-based vs. Windows-based web servers, 11 POP3 mail services, 11 portals offering free hosting, 9 recommended features in a web host, 11 search engines and ISP-provided sites, 9 Secure Socket Layer (SSL) encryption, 10 server-side scripting, 9 SMTP mail services, 11 upload managers, 9 Web Image Formats filter, 213 web pages adding meta-elements with the Page Properties dialog box, 102 alternate language page, 105 anchor (bookmark), 99 attaching stylesheets to, 112 backing up before changing, 245 element, 84 branding a website, 207 Browsed Pages list, 99 browsing recently viewed web pages, 99 changing browser display defaults, 123 character set (charset), 83, 101 creating a back-to-top bookmark, 99 creating a centered, fixed-width layout, 204 creating a hyperlink to a new page, 224 creating a list, 89 creating a two-column layout using absolute positioning, 174 creating an indented block of text, 96 creating headers for a website, 86 creating ordered, structured pages with HTML, 83 CSS 2.1 support for page layout in current browsers, 171 definition lists, 91 doctype declaration, 83–84 E-mail Address option, 101 ensuring sufficient text contrast, 127 element, 84 head section, contents of, 83 header markup, 85 HTML 3.2 or earlier doctype, 84 HTML 4.01 Transitional doctype, 84

    369

    370

    ■INDEX

    web pages, continued element, 83–84 http-equiv browser instructions, 101 hyperlinks, 97 image requirements, 210 language, 102 lists, types of, 88 making a page appear the same in all browsers, 124 making relevant headers, 86 margin attribute, 123 menu and site-navigation conventions, 207 mystery-meat navigation, 207 Netscape 4.x, 113 ordered lists, 88 padding attribute, 123 required elements, 83 restricting the width of a page, 204 screen readers and alt text in images, 211 search engines and properly structured sites, 86 site map, 106 structuring, 84 tables, 91 element, 99, 101 understanding browser display defaults, 122 understanding how to use structural markup, 86 unordered lists, 88 using elements to create page sections, 121 using an e-mail hyperlink, 101 using color in, 126 using JavaScript for client-side scripts, 106 using stylesheets to keep website branding consistent, 230 validating, 211 watermarks, 130 XHTML 1.0 Transitional doctype, 84 web servers, Linux-based vs. Windowsbased, 11

    Web Site tab, 78 Web Site view, 20 WEBASSIST, PayPal buttons, 347 WebDAV, as a rarely used option, 35 web-safe colors, 128 websites blogs, 2 brochure sites, 3 checking domain name availability, 6 choosing a domain name, 6 creating a site map, 4 determining your site’s goals and requirements, 1 e-commerce sites, 2 information sites, 2 objectives for business sites, 2–3 objectives for personal sites, 2 picturing your ideal target visitors, 3 planning your content, 4 registrars, 6, 8 structuring your site, 4 suggestions for improving, 12 understanding your target audience, 1 white-space: nowrap attribute, browser support for, 153 white-space: pre attribute, browser support for, 153 Windows Desktop Search, 230 Windows Mail, 11 Windows servers, case insensitivity of, 30 Windows Vista, 13 Windows XP, Service Pack 2, 13 word-space, 153 Wrap Tag, 175

    ■X XHTML case sensitivity of, 31 outputting of, by ASP.NET 2.0, 283 XHTML 1.0 Transitional doctype, 33, 84

    ■Y Yahoo!, 9, 102