Tải bản đầy đủ

Tài liệu OReilly.Learning.Web.Design.3rd.Edition.Jun.2007 pdf

Learning Web Design

Learning Web Design
Third Edition
A Beginner’s Guide to (X)HTML, Style Sheets, and Web Graphics
Jennifer Niederst Robbins
Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo
Learning Web Design, Third Edition
A Beginner’s Guide to (X)HTML, Style Sheets, and Web Graphics
by Jennifer Niederst Robbins
Copyright © 2007 O’Reilly Media, Inc. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly Media books may be purchased for educational, business, or sales promotional use. Online editions are also avail-
able for most titles (safari.oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-
9938 or corporate@oreilly.com.
Editor:
Linda Laflamme
Production Editor:
Philip Dangler

Cover Designer:
Mark Paglietti
Interior Designer:
Ron Bilodeau
Print History:
March 2001: First edition.
June 2003: Second edition.
June 2007: Third edition.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. “O’Reilly Digital Studio” and related trade dress are
trademarks of O’ReillyMedia, Inc. Photoshop, Illustrator, Dreamweaver, Elements, HomeSite, and Fireworks are either regis-
tered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries. Microsoft and
Expression Web are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other
countries. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trade-
marks. Where those designations appear in this book, and O’ReillyMedia, Inc. was aware of a trademark claim, the designa-
tions have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for
errors or omissions, or for damages resulting from the use of the information contained herein.
This book uses RepKover
TM
, a durable and flexible lay-flat binding.
ISBN-10: 0-596-52752-7
ISBN-13: 978-0-596-52752-5
[C]
v
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Part I
Getting Started
Chapter 1
Where Do I Start? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Am I Too Late? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Where Do I Start? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
What Do I Need to Learn? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Do I Need to Learn Java? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
What Do I Need to Buy? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
What You’ve Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Chapter 2
How the Web Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
The Internet Versus the Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Serving Up Your Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
A Word About Browsers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Web Page Addresses (URLs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
The Anatomy of a Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Putting It All Together. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Browser Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
CONTENTS
Contents
vi
Chapter 3
The Nature of Web Design . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Alternative Browsing Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
User Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Different Platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Connection Speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Browser Window Size and Monitor Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Monitor Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Know Your Audience. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Keeping the Big Picture in Mind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Part II
HTML Markup for Structure
Chapter 4
Creating a Simple Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
(HTML Overview)
A Web Page, Step by Step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Before We Begin, Launch a Text Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Step 1: Start with Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Step 2: Give the Document Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Step 3: Identify Text Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Step 4: Add an Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Step 5: Change the Look with a Style Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
When Good Pages Go Bad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
(X)HTML Review: Document Structure Elements . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Chapter 5
Marking up Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Building Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Adding Line Breaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
The Inline Text Element Round-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Generic Elements (div and span) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Some Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Putting It All Together. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
(X)HTML Review: Text Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Contents
vii
Chapter 6
Adding Links. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
The href Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Linking to Pages on the Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Linking Within Your Own Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Targeting a New Browser Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Mail Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
(X)HTML Review: The Anchor Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Chapter 7
Adding Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
First, a Word on Image Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
The img Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Imagemaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
(X)HTML Review: Image and Imagemap Elements . . . . . . . . . . . . . . . . . . . . . . 127
Chapter 8
Basic Table Markup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
How Tables Are Used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Minimal Table Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Table Headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Spanning Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Cell Padding and Spacing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Captions and Summaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Table Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Wrapping Up Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
(X)HTML Review: Table Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Chapter 9
Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
How Forms Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
The form Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Variables and Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Form Accessibility Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
The Great Form Control Round-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Form Layout and Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
(X)HTML Review: Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Contents
viii
Chapter 10
Understanding the Standards . . . . . . . . . . . . . . . . . . . . . . 165
Everything You’ve Wanted to Know About HTML But Were Afraid to Ask 165
Enter XHTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
From the Browser’s Point of View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Declaring the Document Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Which One Should You Use? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Validating Your Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Character Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Putting It All Together. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Part III
CSS For Presentation
Chapter 11
Cascading Style Sheets Orientation . . . . . . . . . . . . . . . . 187
The Benefits of CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
How Style Sheets Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
The Big Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Moving Forward with CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Chapter 12
Formatting Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
(Plus More Selectors)
The Font Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Changing Text Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
A Few More Selector Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Text Line Adjustments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Underlines and Other “Decorations” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Changing Capitalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Spaced Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
Review: Font and Text Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Contents
ix
Chapter 13
Colors and Backgrounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
(Plus Even More Selectors and External Style Sheets)
Specifying Color Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Foreground Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
Background Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Introducing Pseudoclass Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Pseudoelement Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
Background Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
The Shorthand background Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Finally, External Style Sheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Style Sheets for Print (and Other Media) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Review: Color and Background Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Chapter 14
Thinking Inside the Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
(Padding, Borders, and Margins)
The Element Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Setting the Content Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Padding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Borders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Margins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Assigning Display Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
The Box Model in Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
Review: Basic Box Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Chapter 15
Floating and Positioning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Normal Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Floating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Positioning Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Relative Positioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
Absolute Positioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Fixed Positioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Review: Basic Layout Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
Contents
x
Chapter 16
Page Layout with CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
Page Layout Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
Fixed Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Elastic Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
Page Layout Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Centering a Fixed Width Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
CSS Layouts in Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Chapter 17
CSS Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Style Properties for Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Changing List Bullets and Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Using Lists for Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
Image Replacement Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
CSS Rollovers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Wrapping Up Style Sheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
Review: Table and List Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
Part IV
Creating Web Graphics
Chapter 18
Web Graphics Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
Image Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
Meet the Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
Image Size and Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
Working with Transparency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Web Graphics 101 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
Contents
xi
Chapter 19
Lean and Mean Web Graphics . . . . . . . . . . . . . . . . . . . . . . 387
Why Optimize? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
General Optimization Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
Optimizing GIFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
Optimizing JPEGs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
Optimizing PNGs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Optimize to File Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
Optimization in Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
Part V
From Start to Finish
Chapter 20
The Site Development Process . . . . . . . . . . . . . . . . . . . . . 405
1. Conceptualize and Research. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
2. Create and Organize Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
3. Develop the “Look and Feel” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
4. Produce a Working Prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
5. Test It . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
6. Launch the Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
7. Maintain the Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
The Development Process in Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Chapter 21
Getting Your Pages on the Web. . . . . . . . . . . . . . . . . . . . . 415
www.“YOU”.com! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Finding Server Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
The Publishing Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
Transferring Files with FTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
Test Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
Contents
xii
Appendix A
Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Appendix B
CSS 2.1 Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
xiii
Hello and welcome to the third edition of Learning Web Design! When I first
started writing it, I figured, “It’s just an update I’ll just make a few tweaks
and it will be done in a jiffy.” I couldn’t have been more wrong. As it turns out,
pretty much everything about web design changed since I wrote the second
edition four years ago. Most significantly, web designers as well as browser
developers are finally abiding by the standards for writing and styling web
pages set forth by the World Wide Web Consortium (W3C). You’ll learn a lot
more about these standards throughout the book.
What it means is that using HTML markup for visual effects is out—HTML
for describing the meaning and structure of content is in. Table-based layouts
are out—style sheet-driven layouts are in. And the font element, spacer GIFs,
and other clever hacks of the past forget about it! They’re all history.
This edition has been completely rewritten to be in compliance with the
standards and modern web design practices. The markup chapters emphasize
using HTML to describe your content accurately, not as a tool for formatting
the appearance of text. And now you will find seven chapters on Cascading
Style Sheets (CSS), where the second edition had just one.
But like the first two editions, this book addresses the specific needs and con-
cerns of beginners of all backgrounds, including seasoned graphic designers,
programmers looking for a more creative outlet, office assistants, recent col-
lege graduates, work-at-home moms, and anyone else wanting to learn how
to design web sites. I’ve done my best to put the experience of sitting in my
beginner web design class into a book, with exercises and tests along the way,
so you get hands-on experience and can check your progress.
I start at square one, with answers to common beginner questions and an
explanation of how the Web works. By the end of the book, you’ll have the
skills necessary to create multicolumn CSS layouts with optimized graphic
files, and you’ll know how to get them on the Web. You can start at the very
beginning, or feel free to jump in at any point.
The Companion
Web Site
Be sure to visit the companion
web site for this book at
learningwebdesign.com
. It
features materials for the exercises,
downloadable articles, lists of links
from the book, updates, and other
good stuff.
The Companion
Web Site
Be sure to visit the companion
web site for this book at
learningwebdesign.com
. It
features materials for the exercises,
downloadable articles, lists of links
from the book, updates, and other
good stuff.
PREFACE
Preface
xiv
Acknowledgments
Whether you are reading this book on your own or using it as a companion
to a web design course, I hope it gives you a good head start and that you
have fun in the process.
Acknowledgments
I want to thank my editors, Brian Sawyer, Chuck Toporek, Linda Laflamme,
and Steve Weiss, for their valuable input to this new edition. A special thank
you goes to my technical reviewer, Aaron Gustafson, for his expert guidance,
generosity, and for keeping on the straight and narrow when it comes to
standards compliance.
Thanks also to the others who contributed hands-on time to the creation of
this book: Ron Bilodeau for the updated interior design, Rob Romano for the
figure production, Chris Reilley for helping me envision some of the more
complex figures, Sohaila Abdulali for copyediting, Reg Aubry for writing the
index, and everyone else who helped with the project.
Finally, I want to thank my Mom, Dad, brother Liam, and the whole Robbins
clan for their inspiration and continued support while I labored to crank
out this edition. And it pleases me greatly, Jeff and Arlo, to tell you that I am
finally done writing. Thanks for putting up with me being half there.
O’Reilly Would Like to Hear From You
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international/local)
707-829-0104 (fax)
There is a web page for this book, which lists errata and additional informa-
tion. You can access this page at:
http://www.oreilly.com/catalog/9780596527525
To comment or ask technical questions about this book, send email to:
bookquestions@oreilly.com
For more information about books, conferences, software, Resource Centers,
and the O’Reilly Network, see the O’Reilly web site at:
http://www.oreilly.com
Conventions Used
in This Book
The following typographic
conventions are used in this book:
Italic
Used to indicate URLs, email
addresses, filenames, and
directory names, as well as for
emphasis
Colored roman text
Used for special terms that are
being defined and for cross-
reference.
Constant width
Used to indicate code examples
and keyboard commands
Colored constant width
Used to indicate (X)HTML tags
and attributes, and used for
emphasis in code examples.
Constant width italic
Used to indicate placeholders for
attribute and style sheet property
values.
Conventions Used
in This Book
The following typographic
conventions are used in this book:
Italic
Used to indicate URLs, email
addresses, filenames, and
directory names, as well as for
emphasis
Colored roman text
Used for special terms that are
being defined and for cross-
reference.
Constant width
Used to indicate code examples
and keyboard commands
Colored constant width
Used to indicate (X)HTML tags
and attributes, and used for
emphasis in code examples.
Constant width italic
Used to indicate placeholders for
attribute and style sheet property
values.
IN THIS PART
Chapter 1
Where Do I Start?
Chapter 2
How the Web Works
Chapter 3
The Nature of Web Design
GETTING STARTED
PART
I

3
IN THIS CHAPTER
Am I too late?
Where do I start?
What do I need to learn?
Do I need to learn Java?
What other languages do
I need to know?
What software
and equipment do I
need to buy?
The Web has been around for well over a decade now, experiencing euphoric
early expansion, an economic-driven bust, an innovation-driven rebirth, and
constant evolution along the way. One thing is certain: the Web as a com-
munication and commercial medium is here to stay.
For many people, it’s a call to action—a new career opportunity, an incentive
to keep up with competitors, or just a chance to get stuff out there for the
world to see. But the world of web design can also seem overwhelming.
Through my experience teaching web design courses and workshops, I’ve
had the opportunity to meet people of all backgrounds who are inter ested in
learning how to build web pages. Allow me to introduce you to just a few:
“I’ve been a print designer for 17 years, and now all my clients want web
sites.”
“I work as a secretary in a small office. My boss has asked me to put
together a small internal web site to share company information among
employees.”
“I’ve been a programmer for years, but I want to try my hand at more
visual design. I feel like the Web is a good opportunity to explore new
skills.”
“I am an artist and I want to know how to get samples of my paintings
and sculpture online.”
“I’m a designer who has watched all my colleagues switch to web design
in the last few years. I’m curious about it, but I feel like I may be too
late.”
Whatever the motivation, the first question is always the same: “Where do I
start?” It may seem like there is an overwhelming amount of stuff to learn and
it’s not easy to know where to jump in. But you have to start somewhere.
This chapter attempts to put the learning curve in perspective by answering
the most common questions I get asked by people ready to make the leap. It
provides an introduction to the disciplines, technologies, and tools associated
with web design.
WHERE DO I
START?
CHAPTER
1
Part I: Getting Started
4
Am I Too Late?
Am I Too Late?
That’s an easy one—absolutely not! Although it may seem that everyone in
the whole world has a personal web page, or that your colleagues are all light-
years ahead of you in web experience, I can assure you that you’re not late.
The Web has become an essential part of standard business practice. We’re at
the point where we just assume that a business, regardless of its size, will have
a useful web site. It also remains a uniquely powerful tool for self-publishing,
whether to a small circle of friends or to a worldwide audience. We can be
certain that there will be a steady need for web designers and developers.
Where Do I Start?
Your particular starting point will no doubt depend on your background and
goals. However, a good first step for everyone is to get a basic understanding
of how the Web and web pages work. That you are reading this book now
shows that you are already on the right track. Once you learn the fundamen-
tals, there are plenty of resources on the Web and in bookstores for you to
further your learning in specific areas. One way to get up to speed quickly
is to take an introductory web design class. If you don’t have the luxury of a
full-semester course, even a weekend or one-day seminar can be extremely
useful in getting over that first hump.
You’ll learn that the term “web design” has come to encompass many skills,
and you don’t necessarily need to learn all of them (most people don’t). This
chapter introduces the various disciplines and paths you may take.
Similarly, there are many levels of involvement in web design, from just build-
ing a site for yourself to making it a full-blown career. You may enjoy being
a full-service web site developer or just specializing in one skill, like Flash
development. There are a lot of ways you can go.
If your involvement in web design is purely at the hobbyist level, or if you
have just one or two web projects you’d like to publish, you may find that a
combination of personal research (like reading this book), taking advantage
of available templates, and perhaps even investing in solid web design tools
(such as Dreamweaver from Adobe) may be all you need to accomplish the
task at hand.
If you are interested in pursuing web design as a career, you’ll need to bring
your skills up to a professional level. Employers may not require a web
design degree, but they will expect to see sample web sites that demonstrate
your skills and experience. These sites can be the result of class assignments,
personal projects, or a simple site for a small business. What’s important is
that they look professional and have clean, working HTML and style sheets
behind the scenes. Getting an entry-level job and working as part of a team is
The first step is
understanding the
fundamentals of how the
Web works.
I Just Want a Blog!
You don’t necessarily need to
become a web designer to start
publishing your words and pictures
on the Web. You can start your own
“blog” or personal journal site using
one of the free or inexpensive blog
hosting services. These services
provide templates that spare you
the need to learn HTML (although it
still doesn’t hurt). These are three of
the most popular as of this writing:
Blogger (
www.blogger.com
)
TypePad (
www.typepad.com
)
LiveJournal (
www.livejournal.
com
)
If you use a Mac, Apple’s iWeb
software makes it simple to publish
blogs (including video) using one of
several stylish templates.



What Do I Need to Learn?
Chapter 1, Where Do I Start
5
a great way to learn how larger sites are constructed and can help you decide
which aspects of web design you would like to pursue.
What Do I Need to Learn?
This one’s a big question. The short answer is “not everything.” A more accu-
rate answer depends on where you are starting and what you want to do.
As mentioned earlier, the term “web design” has become a catch-all for a
process that actually encompasses a number of different disciplines, from
graphic design to serious programming. We’ll take a look at each of them.
If you are designing a small web site on your own, you will need to wear
many hats. The good news is that you probably won’t notice. Consider that
the day-to-day upkeep of your household requires you to be part-time chef,
housecleaner, accountant, diplomat, gardener, and construction worker—but
to you it’s just the stuff you do around the house. In the same way, as a solo
web designer, you’ll be part-time graphic designer, writer, producer, and infor-
mation architect, but to you, it’ll just feel like “making web pages.” Nothing
to worry about.
There are also specialists out there whom you can hire to fill in the skills you
don’t have. For example, I have been creating web sites for more than a decade
and I still hire programmers and multimedia developers when my clients
require those features. That allows me to focus on the parts I do well.
Large-scale web sites are almost always created by a team of people, number-
ing from a handful to hundreds. In this scenario, each member of the team
focuses on just one facet of the site building process. If that is the case, you
may be able to simply adapt your current set of skills and interests to the
new medium.
The following are some of the core disciplines involved in the web design
process, along with brief descriptions of the skills required in each area.
Graphic design
Because the Web is a visual medium, web pages require attention to presenta-
tion and design. The graphic designer makes decisions regarding everything
you see on a web page: graphics, type, colors, layout, etc. As in the print
world, graphic designers play an important role in the success of the final
product. If you work as a graphic designer in the web design process, you may
never need to learn any backend programming languages. (I didn’t.)
If you are interested in doing the visual design of commercial sites profes-
sionally, I strongly recommend graphic design training as well as a strong
proficiency in Adobe Photoshop (the industry standard). If you are already
a graphic designer, you will be able to adapt your skills to the Web easily.
If you are not interested
in becoming a jack-of-all-
trades solo web designer,
you may choose to
specialize and work as part
of a team or as a freelance
contractor.
If you are not interested
in becoming a jack-of-all-
trades solo web designer,
you may choose to
specialize and work as part
of a team or as a freelance
contractor.
“Web design” actually combines a
number of disciplines, including:
Graphic design
Information design
Interface design
HTML, style sheet, and graphic
production
Scripting and programming
Multimedia






A t A G l A n c e
Part I: Getting Started
6
What Do I Need to Learn?
Because graphics are a big part of web design, even hobbyist web designers
will need to know how to use some image-editing software, at minimum.
If you don’t have visual design experience, you may want to do some personal
research on the fundamentals of graphic design. The following books will
give you a good start on rounding out your design skills.
The Non-Designer’s Design Book, Second Edition by Robin Williams (Peachpit
Press, 2003)
The Non-Designer’s Web Book, Third Edition by Robin Williams and John
Tollett (Peachpit Press, 2005)
Design Basics, Sixth Edition by David Lauer and Stephen Pentak (Harcourt
College Publishers, 2004)
Graphic Design Solutions, Third Edition by Robin Landa (Thomson Delmar
Learning, 2005).
Information design
One easily overlooked aspect of web design is information design, the orga-
nization of content and how you get to it. Information designers (also called
“information architects”) deal with flow charts and diagrams and may never
touch a graphic or text file; however, they are a crucial part of the creation
of the site.
It is possible to find courses specifically about information design, although
they are likely to be at the graduate level. Again, some personal research and
experience working on a team will go a long way toward rounding out this
skill. If you think you may be interested in this aspect of web development,
check out these books:
Information Architecture for the World Wide Web: Designing Large-Scale Web
Sites, Third Edition by Lou Rosenfeld and Peter Morville (O’Reilly, 2006) for
a good overview.
Information Architecture: Blueprints for the Web, by Christina Wodtke (New
Riders, 2002)
Interface design
If graphic design is concerned with how the page looks, interface design
focuses on how the page works. The concept of usability, how easily visitors
can accomplish their goals on the site, as well as the general experience of
using the site, is a function of the interface design. The interface of a web site
Frontend Versus
Backend
You may hear web designers and
developers say that they specialize in
either the
frontend
or
backend
of
web site creation.
Frontend design
“Frontend” refers to any aspect of the
design process that appears in or
relates directly to the browser. This
book focuses primarily on frontend
web design.
The following tasks are commonly
considered to be frontend disciplines:
Graphic design
Interface design
Information design as it pertains
to the user’s experience of the
site
Site production, including HTML
documents, style sheets and
JavaScript
Backend development
“Backend” refers to the programs
and scripts that work on the server
behind the scenes to make web
pages dynamic and interactive. In
general, backend web development
falls in the hands of experienced
programmers, but it is good for all
web designers to be familiar with
backend functionality.
The following tasks take place on the
backend:
Information design as it pertains
to how the information is
organized on the server
Forms processing
Database programming
Content management systems
Other server-side web
applications using Perl/CGI, PHP,
ASP, JSP, Ruby on Rails, Java and
other programming languages.









What Do I Need to Learn?
Chapter 1, Where Do I Start
7
includes the methods for doing things on a site: buttons, links, navigation
devices, etc., as well as the functional organization of the page. In most cases,
the interface, information archictecture, and visual design of a site are tightly
entwined.
Often, the interface design falls into the hands of a graphic designer by
default; in other cases, it is handled by an interface design specialist or the
information designer. Some interface designers have backgrounds in software
design. It is possible to find courses on interface design; however, this is an
area that you can build expertise in by a combination of personal research,
experience in the field, and common sense. You may also find these popular
books on web usability helpful:
Don’t Make Me Think, A Common Sense Approach to Web Usability, Second
Edition, by Steve Krug (New Riders, 2005)
The Elements of User Experience: User-Centered Design for the Web, by Jesse
James Garrett (New Riders, 2002)
Document production
A fair amount of the web design process involves the creation and trouble-
shooting of the documents, style sheets, scripting, and images that make up
a site. The process of writing HTML and style sheet documents is commonly
referred to as authoring.
The people who handle production need to have an intricate knowledge of
HTML (the markup language used to make web documents) and style sheets,
and often additional scripting or programming skills. At large web design
firms, the team that handles the creation of the files that make up the web site
may be called the “development” or “production” department. In some cases,
the tasks may be separated out into specialized positions for CSS designer,
HTML author/coder, and client-side programmer.
This book will teach you the basics of web authoring, including how to
write HTML documents, create style sheets, and produce web graphics.
Fortunately, it’s not difficult to learn. Once you’ve gotten the fundamentals
under your belt, the trick is to practice by creating pages and learning from
your mistakes. There are also authoring tools that speed up the production
process, as we’ll discuss later in this chapter.
In addition to the HTML document and style sheets, each of the images that
appear on the page need to be produced in a way that is appropriate and
optimized for web delivery. Graphics production techniques are covered in
Part IV.
The topics of information and
interface design are covered in
more detail in my article “Building
Usable Web Sites”, available
as a PDF download at
www.
learningwebdesign.com
.
O n l I n e R e S O U R c e
Part I: Getting Started
8
Do I Need to Learn Java?
Scripting and programming
Advanced web functionality (such as forms, dynamic content, and interactiv-
ity) requires web scripts and sometimes special programs and applications
running behind the scenes. Scripting and programming is handled by web
programmers (also called developers). Developers who specialize in the pro-
gramming end of things may never touch a graphic file or have input on how
the pages look, although they need to communicate well with the informa-
tion and interface designers to make sure their scripts meet intended goals
and user expectations.
Web scripting and programming definitely requires some traditional com-
puter programming prowess. While many web programmers have degrees
in computer science, it is also common for developers to be self-taught.
Developers I know usually start by copying and adapting existing scripts,
then gradually add to their programming skills on the job. If you have no
experience with programming languages, the initial learning curve may be
a bit steep.
Teaching web programming is beyond the scope of this book. It is possible
to turn out competent, content-rich, well-designed sites without the need
for programming, so hobbyist web designers should not be discouraged.
However, once you get into collecting information via forms or serving
information on demand, it is usually necessary to have a programmer on the
team.
Multimedia
One of the cool things about the Web is that you can add multimedia ele-
ments to a site, including sound, video, animation, and Flash movies for
interactivity (see sidebar). You may decide to add multimedia skills to your
web design toolbelt, or you may decide to become a specialist. If you are not
interested in becoming a multimedia developer, you can always hire one.
There is a constant call for professional Flash developers and people who
know how to produce audio and video files that are appropriate for the Web.
Web development companies usually look for people who have mastered the
standard multimedia tools, and have a good visual sensibility and an instinct
for intuitive and creative multimedia design. Professional Flash developers are
also expected to know ActionScript for adding advanced behaviors to Flash
movies and interfaces.
Do I Need to Learn Java?
You’d be surprised at the number of times I’ve heard the following: “I want
to get into web design so I went out and bought a book on Java.” I usually
respond, “Well, go return it!” Before you spend money on a big Java book,
A Little More About
Flash
Adobe Flash (previously Macromedia
Flash, previously FutureSplash) is a
multimedia format created especially
for the Web. Flash gives you the
ability to create full-screen animation,
interactive graphics, integrated audio
clips, even scriptable games and
applications, all at remarkably small
file sizes. Some sites use Flash instead
of (X)HTML for their entire interface,
content, and functionality.
Flash has a number of advantages:
Because it uses vector graphics,
files are small and the movie can
be resized without loss of detail.
Real-time anti-aliasing keeps the
edges smooth.
It is a streaming format, so movies
start playing quickly and continue
to play as they download.
You can use ActionScript to
add behaviors and advanced
interactivity, allowing Flash to
be used as the frontend for
dynamically generated content
or e-commerce functions.
The Flash plug-in is well-
distributed, so support is reliable.
On the downside:
The fact that a plugin is required
to play Flash media makes some
developers squeamish.
Content may be lost for
nongraphical browsers. However,
Flash has many features to
improve accessibility.
The software required to create
Flash content is often expensive,
and the learning curve is steep.
Flash is not appropriate for all sites
and it is not poised to replace
(X)HTML. However, when used well,
it can create a big impact and a
memorable user experience.
For more information, look for
“Adobe Flash” at
Wikipedia.org
.







Do I Need to Learn Java?
Chapter 1, Where Do I Start
9
I’m here to tell you that you don’t need to know Java programming (or any
programming, for that matter) to make web sites.
The following is a list of technologies associated with web development. They
are listed in general order of complexity and in the order that you might want
to learn them. Bear in mind, the only requirements are HTML and Cascading
Style Sheets. Where you draw the line after that is up to you.
HTML/XHTML
HTML (HyperText Markup Langage) is the language used to create web page
documents. The updated version, XHTML (eXtensible HTML) is essentially
the same language with stricter syntax rules. We’ll get to the particulars of
what makes them different in Chapter 10, Understanding the Standards. It is
common to see HTML and XHTML referred to collectively as (X)HTML, as
I will do throughout this book when both apply.
(X)HTML is not a programming language; it is a markup language, which
means it is a system for identifying and describing the various components of
a document such as headings, paragraphs, and lists. You don’t need program-
ming skills—only patience and common sense—to write (X)HTML.
Everyone involved with the Web needs a basic understanding of how HTML
works. The best way to learn is to write out some pages by hand, as we will
be doing in the exercises in this book.
If you end up working in web production, you’ll live and breathe (X)HTML.
Even hobbyists will benefit from knowing what is going on under the hood.
The good news is that it’s simple to learn the basics.
Web-related programming
“languages” in order of increasing
complexity:
HTML/XHTML
Style sheets
JavaScript/DOM scripting
Server-side scripting
XML
Java






A t A G l A n c e
It is common to see HTML
and XHTML referred to
collectively as (X)HTML.
The World Wide Web Consortium
The World Wide Web Consortium (called the W3C for short) is the organization
that oversees the development of web technologies. The group was founded in
1994 by Tim Berners-Lee, the inventor of the Web, at the Massachusetts Institute of
Technology (MIT).
In the beginning, the W3C concerned itself mainly with the HTTP protocol and the
development of the HTML. Now, the W3C is laying a foundation for the future of the
Web by developing dozens of technologies and protocols that must work together
in a solid infrastructure.
For the definitive answer on any web technology question, the W3C site is the place
to go:
www.w3.org
For more information on the W3C and what they do, see this useful page:
www.w3.org/Consortium/
Part I: Getting Started
10
Do I Need to Learn Java?
CSS (Cascading Style Sheets)
While (X)HTML is used to describe the content in a web page, it is Cascading
Style Sheets (CSS) that describe how you want that content to look. In the
web design biz, the way the page looks is known as its presentation. CSS is
now the official and standard mechanism for formatting text and page lay-
outs.
CSS also provides methods for controlling how documents will be presented
in media other than the traditional browser on a screen, such as in print and
on handheld devices. It also has rules for specifying the non-visual presen-
tation of documents, such as how they will sound when read by a screen
reader.
Style sheets are also a great tool for automating production, because you can
make changes to all the pages in your site by editing a single style sheet docu-
ment. Style sheets are supported to some degree by all modern browsers.
Although it is possible to publish web pages using (X)HTML alone, you’ll
probably want to take on style sheets so you’re not stuck with the browser’s
default styles. If you’re looking into designing web sites professionally, profi-
ciency at style sheets is mandatory.
Style sheets are discussed further in Part III.
JavaScript/DOM scripting
Despite its name, JavaScript is not at all related to Java. JavaScript is a script-
ing language that is used to add interactivity and behaviors to web pages,
including these (just to name a few):
Checking form entries for valid entries
Swapping out styles for an element or an entire site
Making the browser remember information about the user for the next
time they visit
JavaScript is a language that is commonly used to manipulate the elements
on the web page or certain browser window functions. There are other web
scripting languages, but JavaScript (also called ECMAScript) is the standard
and most ubiquitous.
You may also hear the term DOM scripting used in relation to JavaScript.
DOM stands for Document Object Model, and it refers to the standard-
ized list of web page elements that can be accessed and manipulated using
JavaScript (or another scripting language). DOM scripting is an updated term
for what used to be referred to as DHTML (Dynamic HTML), now consid-
ered an obsolete approach.
Writing JavaScript is programming, so it may be time-consuming to learn if
you have no prior programming experience. Many people teach themselves



The Web Design
Layer Cake
Contemporary web design is
commonly visualized as being made
up of three separate “layers.”
The content of the document with
its (X)HTML markup makes up
the
Structure Layer
. It forms the
foundation upon which the other
layers may be applied.
Once the structure of the document
is in place, you can add style sheet
information to control how the
content should appear. This is called
the
Presentation Layer
.
Finally, the
Behavior Layer
includes
the scripts that make the page an
interactive experience.
N ot e
When this book says “style sheets” it
is always referring to Cascading Style
Sheets, the standard style sheet language
for the World Wide Web.

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay

×

×