W he
th er
y o
u’ re
a b
eg in
ne r
o r
b ri
ng in
g y
o ur
s ki
lls u
p t
o d
a te
, t hi
s b
o o
k g
iv es
y o
u a
s o
lid f
o ot
in g
in
m o
d er
n w
eb p
ro d
uc ti
o n.
I te
a ch
e a
ch t
o p
ic v
is ua
lly a
t a
p le
a sa
nt p
a ce
, w it
h fr
eq ue
nt e
xe rc
is es
to
le t
yo u
tr y
o ut
n ew
s ki
lls . R
ea d
in g
it f
ee ls
li ke
s it
ti ng
in m
y cl
a ss
ro o
m !
— J
en ni
fe r
R o
b b
in s
Learning Web Design A BEGINNER'S GUIDE TO HTML, CSS, JAVASCRIPT, AND WEB GRAPHICS
Jennifer Niederst Robbins
“Unlike all the other books that start at the beginning, this one will get you to the good stuff, fast. Jennifer will explain every step you need, including some very advanced concepts.”
—JEN SIMMONS, MOZILLA AND W3C CSS WORKING GROUP
5TH EDITION
Fifth Edition
LEARNING WEB DESIGN A BEGINNER’S GUIDE TO HTML, CSS,
JAVASCRIPT, AND WEB GRAPHICS
Jennifer Niederst Robbins
Beijing • Boston • Farnham • Sebastopol • Tokyo
Learning Web Design, Fifth Edition A Beginner’s Guide to HTML, CSS, JavaScript, and Web Graphics
by Jennifer Niederst Robbins
Copyright © 2018 O’Reilly Media, Inc. All rights reserved. Printed in Canada.
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 (oreilly.com/safari). For more information, contact our corporate/institutional sales department: 800-998- 9938 or corporate@oreilly.com.
EDITORS: Meg Foley and Jeff Bleiel
PRODUCTION EDITOR: Kristen Brown
COVER DESIGNER: Edie Freedman
INTERIOR DESIGNER: Jennifer Robbins
PRINT HISTORY:
March 2001: First edition.
June 2003: Second edition.
June 2007: Third edition.
August 2012: Fourth edition.
May 2018: Fifth 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.
ISBN: 978-1-491-96020-2 [TI] [2018-04-16]
CONTENTS
FOREWORD ..... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
PREFACE .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Part I. GETTING STARTED
1. Getting Started in Web Design .......................................... 3 Where Do I Start? ............................................................................. 4
It Takes a Village (Website Creation Roles) ........................................ 4
Gearing Up for Web Design ............................................................ 14
What You’ve Learned ...................................................................... 20
Test Yourself ................................................................................... 20
2. How the Web Works ........................................................ 21 The Internet Versus the Web ........................................................... 21
Serving Up Your Information .......................................................... 22
A Word About Browsers .................................................................. 23
Web Page Addresses (URLs) ............................................................ 24
The Anatomy of a Web Page ............................................................ 27
Putting It All Together ..................................................................... 32
Test Yourself ................................................................................... 34
3. Some Big Concepts You Need to Know ............................ 35 A Multitude of Devices ................................................................... 36
Sticking with the Standards ............................................................. 38
Progressive Enhancement ................................................................ 38
iii
Responsive Web Design .................................................................. 40
One Web for All (Accessibility) ....................................................... 42
The Need for Speed (Site Performance) ............................................ 44
Test Yourself ................................................................................... 46
Part II. HTML FOR STRUCTURE
4. Creating a Simple Page ................................................... 49 A Web Page, Step-By-Step ............................................................... 49
Launch a Text Editor ....................................................................... 50
Step 1: Start with Content ............................................................... 53
Step 2: Give the HTML Document Structure ................................... 55
Step 3: Identify Text Elements ......................................................... 59
Step 4: Add an Image ...................................................................... 62
Step 5: Change the Look with a Style Sheet ..................................... 66
When Good Pages Go Bad .............................................................. 67
Validating Your Documents ............................................................. 68
Test Yourself ................................................................................... 70
Element Review: HTML Document Setup ...................................... 70
5. Marking Up Text .............................................................. 71 Paragraphs ...................................................................................... 71
Headings ......................................................................................... 72
Thematic Breaks (Horizontal Rule) .................................................. 74
Lists ................................................................................................ 74
More Content Elements ................................................................... 78
Organizing Page Content ................................................................. 82
The Inline Element Roundup ........................................................... 88
Generic Elements (div and span) ...................................................... 98
Improving Accessibility with ARIA ............................................... 102
Character Escapes ......................................................................... 105
Putting It All Together ................................................................... 108
Test Yourself ..................................................................................111
Element Review: Text Elements ..................................................... 112
Contents
iv
6. Adding Links ................................................................. 113 The href Attribute ..........................................................................114
Linking to Pages on the Web ......................................................... 115
Linking Within Your Own Site ......................................................116
Targeting a New Browser Window ................................................ 126
Mail Links .................................................................................... 127
Telephone Links ............................................................................ 128
Test Yourself ................................................................................. 128
Element Review: Links .................................................................. 130
7. Adding Images .............................................................. 131 First, a Word on Image Formats .................................................... 132
The img Element ........................................................................... 134
Adding SVG Images ...................................................................... 139
Responsive Image Markup ............................................................ 146
Whew! We’re Finished .................................................................. 159
Test Yourself ................................................................................. 159
Element Review: Images ................................................................162
8. Table Markup ................................................................ 163 How to Use Tables ........................................................................ 163
Minimal Table Structure ............................................................... 165
Table Headers ............................................................................... 167
Spanning Cells .............................................................................. 168
Table Accessibility .........................................................................169
Row and Column Groups ...............................................................171
Wrapping Up Tables ...................................................................... 173
Test Yourself ..................................................................................175
Element Review: Tables ..................................................................176
9. Forms ........................................................................... 177 How Forms Work.......................................................................... 177
The form Element ...........................................................................179
Variables and Content ................................................................... 182
The Great Form Control Roundup................................................. 183
Form Accessibility Features ........................................................... 203
Contents
v
Form Layout and Design ............................................................... 206
Test Yourself ................................................................................. 208
Element Review: Forms ................................................................. 209
10. Embedded Media .......................................................... 215 Window-In-A-Window (iframe) .................................................... 215
Multipurpose Embedder (object) ....................................................218
Video and Audio ........................................................................... 219
Canvas .......................................................................................... 228
Test Yourself ................................................................................. 233
Element Review: Embedded Media ................................................ 234
Part III. CSS FOR PRESENTATION
11. Introducing Cascading Style Sheets .............................. 239 The Benefits of CSS ....................................................................... 239
How Style Sheets Work ................................................................. 240
The Big Concepts .......................................................................... 246
CSS Units of Measurement ............................................................ 253
Developer Tools Right in Your Browser ......................................... 256
Moving Forward with CSS ............................................................ 258
Test Yourself ................................................................................. 259
12. Formatting Text ............................................................ 261 Basic Font Properties ..................................................................... 261
Advanced Typography with CSS3 .................................................. 277
Changing Text Color ..................................................................... 280
A Few More Selector Types ........................................................... 281
Text Line Adjustments .................................................................. 287
Underlines and Other “Decorations” ............................................. 290
Changing Capitalization ................................................................ 291
Spaced Out ................................................................................... 292
Text Shadow ................................................................................. 293
Changing List Bullets and Numbers .............................................. 296
Test Yourself ................................................................................. 299
CSS Review: Font and Text Properties ........................................... 301
Contents
vi
13. Colors and Backgrounds ............................................... 303 Specifying Color Values ................................................................. 303
Foreground Color ...........................................................................311
Background Color ......................................................................... 312
Clipping the Background ................................................................314
Playing with Opacity ..................................................................... 315
Pseudo-Class Selectors ...................................................................316
Pseudo-Element Selectors .............................................................. 320
Attribute Selectors ......................................................................... 323
Background Images ........................................................................324
The Shorthand background Property ............................................. 338
Like a Rainbow (Gradients) ........................................................... 340
Finally, External Style Sheets ......................................................... 348
Wrapping It Up ............................................................................. 351
Test Yourself ................................................................................. 352
CSS Review: Color and Background Properties .............................. 354
14. Thinking Inside the Box ................................................ 355 The Element Box ........................................................................... 355
Specifying Box Dimensions ........................................................... 356
Padding ........................................................................................ 361
Borders ......................................................................................... 366
Margins .........................................................................................376
Assigning Display Types ................................................................ 380
Box Drop Shadows ........................................................................ 382
Test Yourself ................................................................................. 384
CSS Review: Box Properties .......................................................... 384
15. Floating and Positioning ............................................... 387 Normal Flow ................................................................................. 387
Floating ........................................................................................ 388
Fancy Text Wrap with CSS Shapes ............................................... 399
Positioning Basics .......................................................................... 405
Relative Positioning ....................................................................... 407
Absolute Positioning ...................................................................... 408
Fixed Positioning ............................................................................416
Contents
vii
Test Yourself ..................................................................................417
CSS Review: Floating and Positioning Properties ............................418
16. CSS Layout with Flexbox and Grid ................................. 419 Flexible Boxes with CSS Flexbox ....................................................419
CSS Grid Layout ........................................................................... 447
Test Yourself ................................................................................. 478
CSS Review: Layout Properties ...................................................... 482
17. Responsive Web Design ................................................ 485 Why RWD? ................................................................................... 485
The Responsive Recipe .................................................................. 486
Choosing Breakpoints ................................................................... 495
Designing Responsively ................................................................. 499
A Few Words About Testing .......................................................... 512
More RWD Resources ....................................................................514
Test Yourself ..................................................................................516
18. Transitions, Transforms, and Animation ....................... 517 Ease-y Does It (CSS Transitions) .....................................................517
CSS Transforms ............................................................................ 527
Keyframe Animation ..................................................................... 536
Wrapping Up ................................................................................ 542
Test Yourself ................................................................................. 542
CSS Review: Transitions, Transforms, and Animation ................... 545
19. More CSS Techniques .................................................... 547 Styling Forms ................................................................................ 547
Styling Tables ................................................................................ 551
A Clean Slate (Reset and Normalize.css) ........................................ 554
Image Replacement Techniques ..................................................... 556
CSS Sprites .................................................................................... 557
CSS Feature Detection................................................................... 559
Wrapping Up Style Sheets ............................................................. 564
Test Yourself ................................................................................. 564
CSS Review: Table Properties ........................................................ 566
Contents
viii
20. Modern Web Development Tools ................................... 567 Getting Cozy with the Command Line .......................................... 567
CSS Power Tools (Processors) ........................................................ 572
Build Tools (Grunt and Gulp) ........................................................ 578
Version Control with Git and GitHub ............................................ 581
Conclusion .................................................................................... 588
Test Yourself ................................................................................. 589
Part IV. JAVASCRIPT FOR BEHAVIOR
21. Introduction to JavaScript ............................................ 593 What Is JavaScript? ....................................................................... 593
Adding JavaScript to a Page ........................................................... 597
The Anatomy of a Script ................................................................ 598
The Browser Object ....................................................................... 612
Events ........................................................................................... 613
Putting It All Together ....................................................................616
Learning More About JavaScript ....................................................617
Test Yourself ................................................................................. 619
22. Using JavaScript ........................................................... 621 Meet the DOM .............................................................................. 621
Polyfills ......................................................................................... 630
JavaScript Libraries ....................................................................... 632
Big Finish ...................................................................................... 637
Test Yourself ................................................................................. 637
Part V. WEB IMAGES
23. Web Image Basics ......................................................... 641 Image Sources ............................................................................... 641
Meet the Formats .......................................................................... 644
Image Size and Resolution ............................................................. 657
Image Asset Strategy ..................................................................... 660
Favicons ........................................................................................ 665
Contents
ix
Summing Up Images ..................................................................... 668
Test Yourself ................................................................................ 668
24. Image Asset Production ................................................ 671 Saving Images in Web Formats ...................................................... 671
Working with Transparency .......................................................... 676
Responsive Image Production Tips ................................................ 680
Image Optimization ...................................................................... 691
Test Yourself ..................................................................................701
25. SVG .............................................................................. 703 Drawing with XML ....................................................................... 705
Features of SVG as XML ............................................................... 713
SVG Tools ..................................................................................... 718
SVG Production Tips ..................................................................... 721
Responsive SVGs ........................................................................... 724
Further SVG Exploration ............................................................... 731
Test Yourself ................................................................................ 731
And...We’re Done! ......................................................................... 733
Part VI. APPENDICES
A. Answers ........................................................................ 737
B. HTML5 Global Attributes ............................................... 753
C. CSS Selectors, Levels 3 and 4 ........................................ 755
D. From HTML+ to HTML5 .................................................. 759
INDEX .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 767
Contents
x
FOREWORD BY JEN SIMMONS
If you travel to Silicon Valley and navigate between the global headquarters of some of the world’s most famous internet companies, you can head to the Computer History Museum. Wander through the museum, past the ancient mainframes and the story of the punch card, and you’ll eventually find yourself at the beginning of the Wide World Web. There’s a copy of the Mosaic browser on a floppy disk tucked in a book of the same name, a copy of Netscape Navigator that was sold in a box, and something called “Internet in a Box,” the #1 best-selling internet solution for Windows. Then there are the websites. Some of the earliest, most notable, and most important websites are on permanent display, including something called the “Global Network Navigator,” from 1993. It was designed by none other than the author of this book, Jennifer Robbins. Long before most of us had any idea the web existed, or even before many of you were born, Jen was busy designing the first com- mercial website. She’s been there from the very beginning, and has watched, taught, and written about every stage of evolution of the web.
Learning Web Design is now in its 5th edition, with a gazillion new pages and updates from those early days.
I am constantly asked, “What are the best resources for learning web technol- ogy?” I learned by reading books. Blog posts are great, but you also need an in-depth comprehensive look at the subject. In the beginning, all books were beginner books, teaching HTML, URLs, and how to use a browser. When CSS came along, the books assumed you’d already been using HTML, and taught you how to change to the new techniques. Then CSS3 came along, and all the books taught us how to add new CSS properties to our preexist- ing understanding of CSS2. Of course there were always books for beginners, but they were super basic. They never touched on professional techniques for aspiring professionals. Each new generation of books assumed that you had prior knowledge. Great for those of us in the industry. Tough for anyone new.
xi
But how in the world are you supposed to read about two decades of tech- niques, discarding what is outdated, and remembering what is still correct? How are you supposed to build a career from knowledge that’s so basic that you have no idea what real pros code in their everyday jobs?
You can’t. That’s why today when people ask me for a book recommendation, I have only one answer. This book.
This book you are reading now doesn’t require any prior knowledge. You don’t need to have made a web page before, or to have any idea where to get a code editor. It starts at the very beginning. And yet, unlike all the other books that start at the beginning, this one will get you to the good stuff, fast. Jen will explain every step you need, including some very advanced concepts. She’s packed this book full of cutting edge, insider knowledge from top experts.
I honestly don’t know how she does it. How can someone teach the basics and the advanced stuff at the same time? Usually you’ll learn those things years apart, with lots of struggling in the dark in the meantime. Here, Jen will lift you up from wherever you are in your journey, and take you farther. Every one of us—myself included, and I’m on the CSS Working Group (the group of people who invent new CSS)—can learn a lot from this book. I do every time I pick it up.
Pay attention to the notes in the margins. Read the websites she recommends, watch the videos. Jen is giving you a shortcut to a professional network. Follow the people she mentions. Read the links they suggest. These might be your future colleagues. Dare to dream that you will meet them. They are, after all, only a tweet away. It is a small world, full of real people, and you can become part of it all. This book will get you started.
—Jen Simmons Designer and Developer Advocate at Mozilla
Member of the CSS Working Group April 2018
Learning Web Designxii
Foreword
PREFACE
Hello and welcome to the fifth edition of Learning Web Design!
I’ve been documenting web design and development in books like this one for decades, and it continues to fascinate me how the web landscape changes from edition to edition. This fifth edition is no exception! Not only is this version nearly 200 pages longer than the last one, but there are also some significant updates and additions worth noting.
First, some technologies and techniques that were brand new or even experi- mental in the last edition have become nicely settled in. HTML5 is the new normal, and CSS is moving ahead with its modular approach, allowing new technologies to emerge and be adopted one at a time. We’ve largely gotten our heads around designing for a seemingly infinite range of devices. Responsive Web Design is now the de facto approach to building sites. As a result, RWD has earned its own chapter in this edition (Chapter 17, Responsive Web Design). Where in the last edition we pondered and argued how to handle responsive image markup, in this edition, the new responsive image elements are standardized and well supported (Chapter 7, Adding Images). I think we’re getting the hang of this mobile thing!
I’ve seen a lot of seismic shifts in web design over the years, and this time, Flexbox and Grid are fundamentally changing the way we approach design. Just as we saw CSS put table-based layouts and 1-pixel spacer GIFs out of their misery, Flexbox and Grid are finally poised to kick our old float-based layout hacks to the curb. It is nothing short of a revolution, and after 25 years, it’s refreshing to have an honest-to-goodness solution for layout. This edition sports a new (and hefty!) chapter on proper page layout with Flexbox and Grid (Chapter 16, CSS Layout with Flexbox and Grid).
Although knowledge of HTML, CSS, and JavaScript is at the heart of web development, the discipline has been evolving, and frankly, becoming more
O N L I N E r E S O U rC E
The Companion Website Be sure to visit the companion website for this book at learningwebdesign.com. It features materials for the exercises, downloadable articles, lists of links from the book, contact information, and more.
xiii
complicated. I would be shirking my duty if I didn’t at least introduce you to some of the new tools of the trade—CSS processors, feature detection, the command line, task runners, and Git—in a new chapter on the modern web developer toolkit (Chapter 20, Modern Web Development Tools). Sure, it’s more stuff to learn, but the benefit is a streamlined and more efficient workflow.
The biggest surprise to me personally was how much web image production has changed since the fourth edition. Other than the introduction of the PNG format, my graphics chapters have remained essentially unchanged for 20 years. Not so this time around! Our old standby, GIF, is on the brink of retirement, and PNG is the default thanks to its performance advantages and new tools that let even smaller 8-bit PNGs include multiple levels of transpar- ency. But PNG will have to keep its eye on WebP, mentioned in this edition for the first time, which may give it a run for its money in terms of file size and capabilities. The biggest web graphics story, however, is the emergence of SVG (Scalable Vector Graphics). Thanks to widespread browser support (finally!), SVG went from a small “some day” section in the previous edition to an entire “go for it!” chapter in this one (Chapter 25, SVG).
As in the first four editions, this book addresses the specific needs and con- cerns of beginners of all backgrounds, including seasoned graphic designers, programmers looking to expand their skills, and anyone else wanting to learn how to make websites. 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.
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.
HOW THIS BOOK IS ORGANIZED
Learning Web Design, Fifth Edition, is divided into five parts, each dealing with an important aspect of web development.
Part I: Getting Started
Part I lays a foundation for everything that follows in the book. I start off with some important general information about the web design environ- ment, including the various roles you might play, the technologies you might learn, and tools that are available to you. You’ll get your feet wet right away with HTML and CSS and learn how the web and web pages generally work. I’ll also introduce you to some Big Concepts that get you thinking in the same way that modern web designers think about their craft.
Part II: HTML for Structure
The chapters in Part II cover the nitty-gritty of every element and attri- bute available to give content semantic structure. We’ll cover the markup for text, links, images, tables, forms, and embedded media.
Learning Web Designxiv
Preface
Part III: CSS for Presentation
In the course of Part III, you’ll go from learning the basics of Cascading Style Sheets for changing the presentation of text to creating multicolumn layouts and even adding time-based animation and interactivity to the page. It provides an introduction to Responsive Web Design, as well as the tools and techniques that are part of the modern developer’s workflow.
Part IV: JavaScript for Behavior
Mat Marquis starts Part IV out with a rundown of JavaScript syntax so that you can tell a variable from a function. You’ll get to know some ways that JavaScript is used (including DOM scripting) and existing JavaScript tools such as polyfills and libraries that let you put JavaScript to use quickly, even if you aren’t quite ready to write your own code from scratch.
Part V: Web Images
Part V introduces the various image file formats that are appropriate for the web, provides strategies for choosing them as part of a responsive workflow, and describes how to optimize them to make their file size as small as possible. It also includes a chapter on SVG graphics, which offer great advantages for responsive and interaction design.
Part VI: Appendices
Part VI holds reference material such as test answers, lists of HTML global attributes and CSS Selectors, and a look at HTML5 and its history.
TYPOGRAPHICAL CONVENTIONS
Italic
Used to indicate filenames and directory names, as well as for emphasis.
Colored italic
Used to indicate URLs and email addresses.
Colored roman text
Used for special terms that are being defined.
Constant width
Used to indicate code examples and keyboard commands.
Colored constant width
Used for emphasis in code examples.
Constant width italic
Used to indicate placeholders for attribute and style sheet property values.
→ Indicates that a line of code was broken in the text but should remain together on one line in use.
Preface xv
Preface
ACKNOWLEDGMENTS
Once again, many smart and lovely people had my back on this edition.
I want to say a special thanks to my two amazing tech reviewers. I am quite indebted to Elika J. Etemad (fantasai), who, as a member of the W3C CSS Working Group, helped me make this edition more accurate and up-to-date with standards than ever before. She was tough, but the results are worth it. Petter Dessne brought his computer science expertise as well as valuable per- spective as a professor and a reader for whom English is a second language. His good humor and photos of his home in Sweden were appreciated as well!
I am also grateful for this roster of web design superstars who reviewed particular chapters and passages in their areas of expertise (in alphabetical order): Amelia Bellamy-Royds (SVG), Brent Beer (developer tools), Chris Coyier (SVG), Terence Eden (audio/video), Brad Frost (Responsive Web Design), Lyza Danger Gardner (developer tools), Jason Grigsby (images), Val Head (animation), Daniel Hengeveld (developer tools), Mat Marquis (respon- sive images), Eric Meyer (CSS layout), Jason Pamental (web fonts), Dan Rose (images), Arsenio Santos (embedded media), Jen Simmons (CSS layout), Adam Simpson (developer tools), and James Williamson (structured data).
Thanks also to Mat Marquis for his contribution of two lively JavaScript chapters that I could never have written myself, and to Jen Simmons for writ- ing the Foreword and for her ongoing support of Learning Web Design.
I want to thank my terrific team of folks at O’Reilly Media: Meg Foley (Acquisitions Editor), Jeff Bleiel (Developmental Editor), Kristen Brown (Production Editor), Rachel Monaghan (Copyeditor), Sharon Wilkey (Proofreader), and Lucie Haskins (Indexer). Special thanks go to InDesign and book production expert Ron Bilodeau, who turned my design into a tem- plate and a set of tools that made book production an absolute joy. Special thanks also go to Edie Freedman for the beautiful cover design and half a lifetime of friendship and guidance.
Finally, no Acknowledgments would be complete without profound apprecia- tion for the love and support of my dearest ones, Jeff and Arlo.
ABOUT THE AUTHOR
Jennifer Robbins began designing for the web in 1993 as the graphic designer for Global Network Navigator, the first commercial website. In addition to this book, she has written multiple editions of Web Design in a Nutshell and HTML5 Pocket Reference, published by O’Reilly. She is a founder and orga- nizer of the Artifact Conference, which addresses issues related to mobile web design. Jennifer has spoken at many conferences and has taught beginning web design at Johnson and Wales University in Providence, Rhode Island. When not on the clock, Jennifer enjoys making things, indie rock, cooking, travel, and raising a cool kid.
Learning Web Designxvi
Preface
HOW TO CONTACT US 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 or local) 707-829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at bit.ly/ learningWebDesign_5e.
To comment or ask technical questions about this book, send email to bookquestions@oreilly.com.
For more information about our books, courses, conferences, and news, see our website at www.oreilly.com.
Find us on Facebook: facebook.com/oreilly
Follow us on Twitter: twitter.com/oreillymedia
Watch us on YouTube: www.youtube.com/oreillymedia
Preface xvii
Preface
mailto:bookquestions@oreilly.com
I GEttING StartED
IN tHIS CHaPtEr
Content-related disciplines
Design specialties
Frontend development
Backend development
Recommended equipment
Web-related software
The web has been around for more than 25 years 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 commu- nication and commercial medium is here to stay. Not only that, it has found its way onto devices such as smartphones, tablets, TVs, and more. There have never been more opportunities to put web design know-how to use.
Through my experience teaching web design courses and workshops, I’ve had the opportunity to meet people of all backgrounds who are interested 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 I am feeling pressure to pro- vide web design services.”
“I’ve been a programmer for years, but I want shift my skills to web develop- ment because there are good job opportunities in my area.”
“I tinkered with web pages in high school and I think it might be something I’d like to do for a living.”
“I’ve made a few sites using themes in WordPress, but I’d like to expand my skills and create custom sites for small businesses.”
Whatever the motivation, the first question is always the same: “Where do I start?” It may seem like there is a mountain of stuff to learn, and it’s not easy to know where to jump in. But you have to start somewhere.
This chapter provides an overview of the profession before we leap into building sites. It begins with an introduction to the roles and responsibilities associated with creating websites, so you can consider which role is right for you. I will also give you a heads-up on the equipment and software you will be likely to use—in other words, the tools of the trade.
GETTING STARTED IN WEB DESIGN
1 CHAPTER
3
WHERE DO I START?
Maybe you are reading this book as part of a full course on web design and development. Maybe you bought it to expand your current skill set on your own. Maybe you just picked it up out of curiosity. Whatever the case, this book is a good place to start learning what makes the web tick.
There are many levels of involvement in web design, from building a small site for yourself to making it a full-blown career. You may enjoy being a “full- stack” web developer or just specializing in one skill. There are a lot of ways you can go.
If you are interested in pursuing web design or production 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 working sample sites that demonstrate your skills and experience. These sites can be the result of class assignments, personal projects, or a site for a small business or organiza- tion. What’s important is that they look professional and have well-written, clean HTML; style sheets; and scripts behind the scenes.
If your involvement is at a smaller scale—say you just have a site or two you’d like to publish—you may find using a template on an online website service is a great head start (see the sidebar “I Just Want My Own Site”). Most allow you to tweak the underlying code, so what you learn in this book will help you customize the template to your liking.
IT TAKES A VILLAGE (WEBSITE CREATION ROLES)
When I look at a site, I see the multitude of decisions and areas of expertise that went into building it. Sites are more than just code and pictures. They often begin with a business plan or other defined mission. Before they launch, the content must be created and organized, research is performed, design from the broadest goals to finest details must happen, code gets written, and everything must be coordinated with what’s happening on the server to bring it to fruition.
Big, well-known sites are created by teams of dozens, hundreds, or even thou- sands of contributors. There are also sites that are created and maintained by a team with only a handful of members. It is also absolutely possible to create a respectable site with a team of only yourself. That’s the beauty of the web.
In this section, I’ll introduce you to the various disciplines that contribute to the creation of a site, including roles related to content, design, and code. You may end up specializing in just one area of expertise, working as part of a team of specialists. If you are designing sites on your own, you will need to wear many hats. Consider that the day-to-day upkeep of your household
I Just Want My Own Site You don’t necessarily need to become a web designer or developer to start publishing on the web. There are many website hosting services that provide templates and drag-and-drop interfaces that make it easy to build a site without any code know-how. They can be used for anything from full-service ecommerce solutions to small, personal sites (although some services are better suited to one more than the other).
Here are a few of the most popular site building services as of this writing:
• WordPress (www.wordpress.com) • Squarespace (squarespace.com) • Wix (wix.com) • SiteBuilder (sitebuilder.com) • Weebly (weebly.com) There are many similar services available, so it’s worth searching the web to find one that’s right for you.
Part I. Getting Started
Where Do I Start?
4
http://www.wordpress.com
requires you to be part-time chef, housecleaner, accountant, diplomat, gar- dener, and construction worker—but to you it’s just the stuff you do around the house. As a solo designer, you’ll handle many web-related disciplines, but it will just feel like the stuff you do to make a website.
Content Wrangling Anyone who uses the title “web designer” needs to be aware that everything we do supports the process of getting the content, message, or functionality to our users. Furthermore, good writing can help the user interfaces we create be more effective, from button labels to error messages.
Of course, someone needs to create all that content and maintain it—don’t underestimate the resources required to do this successfully. Good writers and editors are an important part of the team. In addition, I want to call your attention to two content-related specialists in modern web development: the Information Architect (IA) and the Content Strategist.
Information architecture An Information Architect (also called an Information Designer) organizes the content logically and for ease of findability. They may be responsible for search functionality, site diagrams, and how the content and data are organized on the server. Information architecture is inevitably entwined with UX and UI design (defined shortly) as well as content management. If you like organizing or are gaga for taxonomies, information architecture may be the job for you. The definitive text for this field as it relates to the web is Information Architecture: For the Web and Beyond, by Louis Rosenfeld and Peter Morville (O’Reilly).
Content strategy When the content isn’t right, the site can’t be fully effective. A Content Strategist makes sure that every bit of text on a site, from long explanatory text down to the labels on buttons, supports the brand identity and mar- keting goals of the organization. Content strategy may also extend to data modeling and content management on a large and ongoing scale, such as planning for content reuse and update schedules. Their responsibilities may also include how the organization’s voice is represented on social media. A good place to learn more is the book Content Strategy for the Web, 2nd Edition, by Kristina Halvorson and Melissa Rich (New Riders).
All Manner of Design Ah, design! It sounds fairly straightforward, but even this simple requirement has been divided into a number of specializations when it comes to creating sites. Here are a few of the job descriptions related to designing a site, but
1. Getting Started in Web Design
It Takes a Village (Website Creation Roles)
5
bear in mind that the disciplines often overlap and that the person calling herself the “designer” often is responsible for more than one (if not all) of these responsibilities.
User Experience, Interaction, and User Interface design Often, when we think of design, we think about how something looks. On the web, the first matter of business is designing how the site works. Before you pick colors and fonts, it is important to identify the site’s goals, how it will be used, and how visitors move through it. These tasks fall under the dis- ciplines of User Experience (UX) design, Interaction Design (IxD), and User Interface (UI) design. There is a lot of overlap between these responsibilities, and it is not uncommon for one person or team to handle all three.
The User Experience designer takes a holistic view of the design process— ensuring the entire experience with the site is favorable. UX design is based on a solid understanding of users and their needs based on observations and interviews. According to Donald Norman (who coined the term), UX design includes “all aspects of the user’s interaction with the product: how it is perceived, learned, and used.” For a website or application, that includes the visual design, the user interface, the quality and message of the content, and even the overall site performance. The experience must be in line with the organization’s brand and business goals in order to be successful.
The goal of the Interaction Designer is to make the site as easy, efficient, and delightful to use as possible. Closely related to interaction design is User Interface design, which tends to be more narrowly focused on the functional organization of the page as well as the specific tools (buttons, links, menus, and so on) that users use to navigate content or accomplish tasks.
The following are deliverables that UX, UI, or interaction designers produce:
User research and testing reports
Understanding the needs, desires, and limitations of users is central to the success of the design of the site or web application. The approach of designing around the user’s needs is referred to as User-Centered Design (UCD), and it is central to contemporary web design. Site designs often begin with user research, including interviews and observations, in order to gain a better understanding of how the site can solve problems or how it will be used. It is typical for designers to do a round of user testing at each phase of the design process to ensure the usability of their designs. If users are having a hard time figuring out where to find content or how to move to the next step in a process, then it’s back to the drawing board.
Wireframe diagrams
A wireframe diagram shows the structure of a web page using only out- lines for each content type and widget (FIGURE 1-1). The purpose of a wireframe diagram is to indicate how the screen real estate is divided and where functionality and content such as navigation, search boxes, form
Part I. Getting Started
It Takes a Village (Website Creation Roles)
6
elements, and so on, are placed. Colors, fonts, and other visual identity elements are deliberately omitted so as not to distract from the structure of the page. These diagrams are usually annotated with instructions for how things should work so the development team knows what to build.
Site diagram
A site diagram indicates the structure of the site as a whole and how indi- vidual pages relate to one another. FIGURE 1-2 shows a very simple site diagram. Some site diagrams fill entire walls!
SEARCH
LOGO
[ PROMOTIONAL IMAGES ROTATE HERE ]
Today’s Specials
Log in or Create Account
ABOUT US Company News Jobs Policies Contact
SOCIAL Facebook Twitter Try our app
SERVICE FAQ Live support Site map
Product 1 Product 2 Product 4Product 3 Product 6Product 5
Category
All categories
Category1
Category2
Category3
Category4
Category5
Category6
contact | store locator | support | CART
1 2 3 4
copyright statement
FIGURE 1-1. Wireframe diagram.
Home page
Email form
FAQ
Text
Book Web design services
Resume
Samples
External links
Contact
FIGURE 1-2. A simple site diagram.
1. Getting Started in Web Design
It Takes a Village (Website Creation Roles)
7
Storyboards and user flow charts
A storyboard traces the path through a site or application from the point of view of a typical user (a persona in UX lingo). It usually includes a script and “scenes” consisting of screen views or the user interacting with the screen. The storyboard aims to demonstrate the steps it takes to accomplish tasks, outlines possible options, and also introduces some standard page types. FIGURE 1-3 shows a simple storyboard. A user flow chart is another method for showing how the parts of a site or application are connected, but it tends to focus on technical details rather than telling a story. For example, “when the user does this, it triggers that function on the server.” It is common for designers to create a user flow chart for the steps in a process such as member registration or online payments.
FIGURE 1-3. A typical storyboard (courtesy of Adaptive Path and Brandon Schauer).
There are many books on UX, interaction, and UI design, but these are a few of the classics to get you started:
• The Elements of User Experience: User-Centered Design for the Web and Beyond by Jesse James Garrett (New Riders)
• Don’t Make Me Think, Revisited: A Common Sense Approach to Web Usability by Steve Krug (New Riders)
• The Design of Everyday Things by Don Norman (Basic Books)
• About Face: The Essentials of Interaction Design, 4th Edition by Alan Cooper, Robert Reimann, David Cronin, and Christopher Noessel (Wiley)
• Designing Interfaces, 2nd Edition by Jenifer Tidwell (O’Reilly)
Part I. Getting Started
It Takes a Village (Website Creation Roles)
8
• 100 Things Every Designer Needs to Know about People by Susan Weinschenk (New Riders)
• Designing User Experience: A Guide to HCI, UX and Interaction Design by David Benyon (Pearson)
Visual (graphic) design Because the web is a visual medium, web pages require attention to their visual presentation. First impressions are everything. A graphic designer cre- ates the “look and feel” of the site—logos, graphics, type, colors, layout, and so on—to ensure that the site makes a good first impression and is consistent with the brand and message of the organization it represents.
There are many methods and deliverables that can be used to present a visual design to clients and stakeholders. The most traditional are sketches or mock- ups (created in Photoshop or a similar tool) of the way the site might look, such as the home page mockups shown in FIGURE 1-4.
Now that sites appear on screens of all sizes, many designers prefer to discuss the visual identity (colors, fonts, image style, etc.) in a way that isn’t tied to a specific layout like the typical desktop view shown in FIGURE 1-4. The idea is to agree upon a visual language for the site before production begins.
One option for separating style from screen size is to use style tiles, a tech- nique introduced by Samantha Warren (see Note). Style tiles include examples of color schemes, branding elements, UI treatments, text treatment, and mood (FIGURE 1-5). Once the details are decided upon, they can be implemented into working prototypes and the final site. For more on this technique, visit Samantha’s excellent site, styletil.es, where you can download a template.
Graphic designers may also be responsible for producing the image assets for the site. They will need to know how to optimize images for the fastest delivery and how to address the requirements of varying screen sizes. It is also common for the development team to handle image optimization, but I think it is a skill every visual designer should have. We’ll discuss image opti- mization in Chapter 24, Image Asset Production.
FIGURE 1-4. Look-and-feel sketches (mockups) for a simple site.
FIGURE 1-5. Style tile technique introduced by Samantha Warren.
NOTE
Designer Dan Mall uses a similar approach that he calls “element collag- es.” An element collage is a collection of design elements that give the site its unique look and feel, but like style tiles, is not tied to a particular screen layout. Read his article at v3.danielmall.com/ articles/rif-element-collages/.
1. Getting Started in Web Design
It Takes a Village (Website Creation Roles)
9
Designers may also be responsible for creating a style guide that documents style choices, such as fonts, colors, and other style embellishments, in order to keep the site consistent over time. For a list of examples, articles, books, and podcasts about web style guides, visit the “Website Style Guide Resources” page at styleguides.io.
Do Designers Need to Learn to Code? In short, yes. A basic familiarity with HTML and CSS is now a requirement of anybody joining a web design team. You may not be responsible for creating the final production code for the site, but as HTML and CSS are the native languages of your medium, you need to know your way around them. Some designers also learn JavaScript, but others draw the line there and let a developer handle the programming.
Code is becoming more central to the visual designer’s workflow. Where once Photoshop was all you needed to mock up web page designs to send them to production, mockups fixed to a particular size fall short of describing a page that needs to flex to a wide range of screen sizes. For that reason, designers are building their own working prototypes as deliverables that communicate how the design will look and behave in users’ hands.
Code Slinging A large share of the website building process involves creating and trouble- shooting the documents, style sheets, scripts, and images that make up a site. At web design firms, the team that handles the creation of the files that make up the site (or templates for pages that get assembled dynamically) is usually called the development or production department.
Development falls under two broad categories: frontend development and backend development. Once again, these tasks may fall to specialists, but it is just as common for one person or team to handle both responsibilities.
Frontend development Frontend refers to any aspect of the design process that appears in or relates directly to the browser. That includes HTML, CSS, and JavaScript, all of which you will need to have intricate knowledge of if you want a job as a web developer. Let’s take a quick look at each.
Authoring/markup (HTML)
Authoring is the process of preparing content for delivery on the web, or more specifically, marking up the content with HTML tags that describe its content and function.
HTML (HyperText Markup Language) is the authoring language used to cre- ate web page documents. The current version (and the version documented
at a G L a N C E
Frontend Development Frontend development includes the following web technologies:
• HyperText Markup Language (HTML)
• Cascading Style Sheets (CSS) • JavaScript and DOM scripting,
including AJAX and JavaScript- based frameworks
Part I. Getting Started
It Takes a Village (Website Creation Roles)
10
in this book) is HTML 5.2. Appendix D, From HTML+ to HTML5, tells the his- tory of HTML and lists what makes HTML5 unique.
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. The markup indicates the document’s underlying structure (you can think of it as a detailed, machine- readable outline). You don’t need programming skills—only patience and common sense—to write HTML.
The best way to learn HTML is to write out some pages by hand, as we will be doing in the exercises in Part II of this book.
Styling (CSS)
While HTML is used to describe the content in a web page, Cascading Style Sheets (CSS) describe how that content should look (see Note). The way the page looks is referred to as its presentation. Fonts, colors, background images, line spacing, page layout, and so on, are all controlled with CSS. You can even add special effects and basic animation to your page.
The CSS specification also provides methods for controlling how documents will be presented in contexts other than a browser, such as in print or read aloud by a screen reader; however, we won’t be covering them much here.
Although it is possible to publish web pages using HTML alone, you’ll prob- ably want to take on style sheets so you’re not stuck with the browser’s default styles. If you’re looking into designing websites professionally, either as a designer or as a developer, proficiency at style sheets is mandatory.
JavaScript and DOM scripting
JavaScript is a scripting language that adds interactivity and behaviors to web pages, including these (to name just a few):
• Checking form entries for valid entries
• Swapping out styles for an element or an entire site
• Loading scrolling feeds with more content automatically
• Making the browser remember information about users
• Building interface widgets, such as embedded video players or special form inputs
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).
Frontend developers may also be required to be familiar with JavaScript frameworks (such as React, Bootstrap, Angular, and others) that automate a lot of the production process. They’ll likely also need to be handy with AJAX
NOTE
When this book uses the term “style sheets,” it always refers to Cascading Style Sheets, the standard style sheet language for the World Wide Web. Style sheets (including what “cascading” means!) are discussed further in Part III.
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 such as HTML, CSS, and JavaScript. 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 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 to any web technology question, the W3C site is the place to go: www.w3.org. For more information on the W3C and what it does, see this useful page: www.w3.org/Consortium/.
1. Getting Started in Web Design
It Takes a Village (Website Creation Roles)
11
http://www.w3.org/Consortium/
(which stands for “Asynchronous JavaScript And XML”), a technique used to load content in the background, allowing the page to update smoothly with- out reloading (like those automatically refreshing feeds).
Web scripting definitely requires some traditional computer programming prowess. While many web developers have degrees in computer science, it is also common for developers to be self-taught. A few developers I know start- ed by copying and adapting existing scripts, then gradually added to their programming skills with each new project. Still, if you have no experience with programming languages, the initial learning curve may be a bit steep.
If you want to be a web developer for a living, JavaScript is a basic require- ment. Designers will benefit from understanding what JavaScript can do, but may not need to learn to write it if they are working with a development team. Chapter 21, Introduction to JavaScript, will get you started understand- ing how it works, and I recommend Learning JavaScript by Ethan Brown (O’Reilly) to learn more.
Backend development Backend developers focus on the server, including the applications and data- bases that run on it. They may be responsible for installing and configuring the server software (we’ll be looking more at servers in Chapter 2, How the Web Works). They will certainly be required to know at least one, and prob- ably more, server-side programming languages, such as PHP, Ruby, .NET (or ASP.NET), Python, or JSP, in order to create applications that provide the functionality required by the site. Applications handle tasks and features like forms processing, content management systems (CMSs), and online shop- ping, just to name a few.
Additionally, backend developers need to be familiar with configuring and maintaining databases that store all of the data for a site, such as the content that gets poured into templates, user accounts, product inventories, and more. Some common database languages include MySQL, Oracle, and SQL Server.
Backend development is well beyond the scope of this book, but it is impor- tant to know the sorts of tasks that get taken care of at the server level. You should be aware that it is possible to get functionality like shopping carts, mailing lists, and so on as prepackaged solutions from your hosting company without having to program it from scratch.
at a G L a N C E
Backend Development The following technologies are typically in the domain of the backend developer:
• Server software (Apache, Microsoft IIS)
• Web application languages (PHP, Ruby, Python, JSP, ASP.NET)
• Database software (MySQL, Oracle, SQL Server)
Full-Stack Developers and Unicorns When looking for a job in web development, you will frequently see posts looking for “full-stack” developers. That means a person who is fluent in both frontend (HTML, CSS, JavaScript) and backend (server applications, databases) languages.
There is a rare breed of web designer who can handle all of the tasks mentioned earlier—from content strategy to UX to frontend development to what happens on the server. These folks are known in the biz as “unicorns.” I’ve met a few!
Part I. Getting Started
It Takes a Village (Website Creation Roles)
12
Other Roles Not surprisingly, there are a myriad of other roles that contribute to the cre- ation and maintenance of a site. Here are a few common roles that fall just outside the moniker “web design.”
Product manager
The product manager of a website or application guides its design and development in a way that meets business goals. This member of the team must have a thorough understanding of the target market as well as the processes involved in the creation of the site itself. Product manag- ers develop the overall strategy for the site from a marketing perspective, including how and when it gets released.
Project manager
The project manager coordinates the designers, developers, and everyone else who is working on the site. They manage things like timelines, devel- opment approaches, deliverables, and so on. The project manager works with the product manager and other product owners to make sure that the project gets done on time and on budget.
SEO specialist
A website or application isn’t much good if nobody knows it exists, so it is crucial that a site be easily found by search engines. Search Engine Optimization (SEO) is a discipline focused on tweaking the site structure and code in a way that increases the chances it will be highly ranked in search results. There may be an SEO specialist on the in-house team, or a company may choose to hire an outside SEO firm. SEO is sometimes perceived as a dark art, but there are many ways to improve findability that are not underhanded. In fact, the number one technique for improv- ing SEO is simply having good content with savvy HTML markup.
Multimedia producers
One of the cool things about the web is that you can add multimedia ele- ments to a site, including sound, video, animation, and even interactive games. Creating multimedia elements is generally best left to artists and technicians in those fields, although they may be part of the web team if video, animation, or interactivity are core to the site’s mission.
That concludes our stroll through the virtual village of workers involved in the creation of a website. The larger the site, the more likely each team member will have a narrow specialization and job titles like “UX Lead for Error Messages.” More likely, everybody on the team will possess a spec- trum of skills, and the lines between disciplines will blur. For example, I do Interaction and User Interface design, graphic design, HTML, and CSS, but I do not write JavaScript, work on the server, or get involved with content organization. In this book, I aim to give you a foundation in the frontend technologies that will prepare you for a number of roles.
1. Getting Started in Web Design
It Takes a Village (Website Creation Roles)
13
GEARING UP FOR WEB DESIGN
It should come as no surprise that professional web designers require a fair amount of gear, both hardware and software. One question I’m frequently asked is, “What do I need to buy?” I can’t tell you specifically what to buy, but I will provide an overview of the typical tools of the trade.
Equipment For a comfortable web development environment, I recommend the follow- ing equipment:
A solid, up-to-date computer
Macintosh, Windows, or Linux is fine, so use whatever you have and are comfortable with. Creative departments in professional web development companies tend to be Mac-based. For backend work, Linux and Windows are popular. Although it is nice to have a super-fast machine, the files that make up web pages are very small and tend not to be too taxing on com- puters. Unless you’re getting into sound and video editing, don’t worry if your current setup is not the very latest and greatest.
A large monitor
Although not a requirement, a large monitor makes life easier. The more monitor real estate you have, the more windows and control panels you can have open at the same time. You can also see more of your page to make design decisions. If you’re using a large monitor, just make sure you design for users with smaller monitors and devices in mind.
(Soft) Skills Every Web Designer Needs We’ve focused on quite a few technical skills that will be helpful in building websites. I would like to mention a few more—often overlooked—skills that are just as critical to your success.
Excellent communication skills In your work, you will need to communicate in person, on the phone, in email, and in text messaging tools with clients, team members, and superiors. Be clear, proactive, and straightforward with what you have to say. Good communication requires not only that you express yourself clearly, but also that you be a good listener. Make sure that you understand issues being discussed, and don’t be afraid to ask for clarification if you don’t.
Flexibility Be able to change direction quickly because not only does web technology change quickly, but you will no doubt be thrown curveballs in your day-to-day work as well. For
example, you may arrive at work one day to find that the client has changed your priorities completely. You might find that they’ve cancelled your project entirely. You might be asked to learn new skills and shift positions in the team. Staying adaptable is the key to survival.
Critical thinking and good judgment Problem-solving is central to all of the disciplines related to web design, so you need to be able to use critical thinking skills to come up with solutions and always employ basic common sense.
A good attitude Creating sites means being part of a team, even if you work at home as a freelancer. Be mindful that the attitude with which you approach your work is contagious, so strive to be a positive and friendly team member.
Part I. Getting Started
Gearing Up for Web Design
14
A second computer for testing
Many designers and developers find it useful to have a test computer run- ning a different platform than the computer they use for development (i.e., if you design on a Mac, test on a PC). Because browsers work differently on Macs than on Windows machines, it’s critical to test your pages in as many environments as possible, and particularly on the current Windows operating system. If you are a hobbyist web designer working at home, you could check your pages on a friend’s machine. Mac users should check out the “Run Windows on Your Mac” sidebar.
Mobile devices for testing
The web has gone mobile! That means it is absolutely critical that you test the appearance and performance of your site on browsers on smart- phones and tablet devices. Device testing is discussed in Chapter 17, Responsive Web Design.
A scanner and/or camera
If you anticipate making your own images and textures, you’ll need some tools for creating them.
Web Production Software There’s no shortage of software available for creating web pages. In the early days, we just made do with tools originally designed for print. Today, there are wonderful tools created specifically with web design in mind that make the process more efficient. It is a delicate business listing software in a book such as this because a) there are so many programs, b) everyone has their personal favorite, and c) new tools come along so rapidly that there are surely newer, cooler options that you have access to that didn’t exist as I wrote this.
Run Windows on Your Mac If you have a Macintosh computer with an Intel chip running macOS (Leopard or later), you don’t need a separate computer to test in a Windows environment. It is now possible to run Windows right on your Mac using the free Boot Camp application, which allows you to switch to Windows on reboot.
There are several other VM (Virtual Machine) products for macOS that allow you to toggle between Mac and Windows, including these:
• VMFusion (www.vmware.com/fusion) is a commercial product with a free trial you can download.
• Parallels Desktop for Mac (www.parallels.com) is also a commercial product with a free trial.
• Oracle VirtualBox (virtualbox.org) is a free program that allows you to run a number of guest operating systems, including Windows and several flavors of Unix.
All VM products require that you purchase a copy of Microsoft Windows, but it sure beats buying a whole machine.
NOTE
To do the exercises in this book, all you’ll need is the text editor that came with your operating system and free image creation software. There is no need to purchase anything to follow along.
1. Getting Started in Web Design
Gearing Up for Web Design
15
http://www.vmware.com/fusion
http://www.parallels.com
That said, here is a general overview of the types of software that comprise the tools of our trade, along with a few specific mentions of the most popular in each class.
Coding tools Although you can get by with the simple text editors that come with your computer, a dedicated code editor makes the task of writing HTML, CSS, and JavaScript much easier. Code editors understand the syntax of the code you write, so they can do things for you like color coding, error detection, and automatically finishing simple tasks like closing HTML tags. Some provide page previews so you can view the results of your code as you work.
FIGURE 1-6 shows how an HTML document looks in the Sublime Text editor. Here are just a few of the better-known code editors for web production that are worth exploring:
• Sublime Text (sublimetext.com)
• Atom (free from GitHub; atom.io)
• Brackets (free from Adobe; brackets.io)
• CodeKit (codekitapp.com; Mac only)
• Adobe Dreamweaver (www.adobe.com/products/dreamweaver.html)
• Coda (panic.com/coda/)
• Microsoft Visual Studio (visualstudio.com)
FIGURE 1-6. Sublime Text is one example of a dedicated code editor.
Part I. Getting Started
Gearing Up for Web Design
16
http://www.adobe.com/products/dreamweaver.html
User interface and layout tools There is a new breed of interface design tools made specifically for websites and other applications. Because they have been designed from scratch with interface design in mind, they seem to anticipate a web designer’s every need. Interface design tools make it easy to design multiple layouts (such as layouts at various screen sizes) as well as export images and code for use in production. Some allow basic interactivity such as clicks and swipes, so your mockups can be shared online and used for basic interface testing.
Sketch (sketchapp.com, Mac only), shown in FIGURE 1-7, is extremely popular at the time of this writing. Other options include the following:
• Affinity Designer (affinity.serif.com/en-us/designer/)
• Adobe XD (www.adobe.com/products/xd.html)
• Figma (figma.com)
• UXPin (uxpin.com)
FIGURE 1-7. Sketch (Mac only) is an example of an interface design tool.
Web graphic creation tools It is certainly possible to create all of the images you need for a site by using one of the interface design tools just listed. There are also programs that focus solely on image creation that can export files in web-appropriate for- mats. For professional designers, the Adobe Creative Cloud (adobe.com) suite of tools, which includes Photoshop (FIGURE 1-8), Illustrator, and other high- end design tools, is worth the investment.
If the Adobe monthly subscription fee is out of reach, you can try lower-cost alternatives that provide many of the same features. The number of graphics tools out there is dizzying, so I’m gathering just a few here:
1. Getting Started in Web Design
Gearing Up for Web Design
17
• GIMP (free, open source; gimp.org)
• Corel PaintShop Pro (for photo editing; paintshoppro.com; Windows only)
• Corel Draw (for vector drawing; coreldraw.com; Windows only)
• Pixelmator (pixelmator.com; Mac only)
The following image editors work right in your browser, without the need to download a program, although you do need to pay for an account:
• SumoPaint (sumopaint.com)
• Pixlr (pixlr.com)
FIGURE 1-8. Adobe Photoshop is the professional standard for image editing.
A variety of browsers One of the biggest challenges for web designers is that our sites may look and behave differently from browser to browser. For this reason, it is critical that we test our designs early and often on the widest range of browsers possible. These are the browsers designers and developers keep around for testing:
• Chrome (google.com/chrome)
• Firefox (www.mozilla.org)
• MS Edge (www.microsoft.com/en-us/windows/microsoft-edge; Windows only)
• Internet Explorer 9–11 (www.microsoft.com; search “Internet Explorer”; Windows only)
• Safari (support.apple.com/downloads/#safari; Mac only)
• Opera (opera.com)
Part I. Getting Started
Gearing Up for Web Design
18
http://www.microsoft.com/en-us/windows/microsoft-edge
http://www.microsoft.com
You will also need to test on a variety of smartphone browsers including iOS Safari, Android browsers, and third-party mobile browsers. We will discuss mobile testing further in Chapter 17.
File management and transfer tools Web design and development involves a lot of moving files around, particu- larly from the computer where you do your work to the server computer that hosts the site. To move files across the internet, you use an FTP (short for File Transfer Protocol) program. You will find that many hosting services offer their own FTP tools for uploading your files to their servers. Many of the code editors listed earlier also include built-in FTP functionality. Or, you can use a standalone FTP program, such as one of these:
• Filezilla (filezilla-project.org; free, all platforms)
• Cyberduck (cyberduck.io; Mac and Windows)
• WinSCP (winscp.net/eng/index.php; free, Windows only)
• Transmit (panic.com/transmit/; Mac only)
You may also find it useful to have a terminal application (command-line tool) that allows you to type Unix commands for setting file permissions, moving or copying files and directories, or managing the server software. Command-line tools, which have a number of uses in web design and devel- opment workflow, are discussed in more detail in Chapter 20, Modern Web Development Tools:
• Terminal (installed with macOS; shown in FIGURE 1-9)
• Cygwin (cygwin.com; Linux emulator for Windows that includes a command-line tool)
FIGURE 1-9. The Terminal command-line tool for macOS.
1. Getting Started in Web Design
Gearing Up for Web Design
19
https://winscp.net/eng/index.php
WHAT YOU’VE LEARNED
I hope that this chapter has given you an overview of the many roles and responsibilities that fall under the umbrella of “web design.” I also hope that you come away realizing that you don’t need to learn everything. And even if you want to learn everything eventually, you don’t need to learn it all at once. So relax, and don’t worry. The other good news is that, while many profes- sional tools exist, it is possible to create a basic website and get it up and run- ning without spending much money by using freely available or inexpensive tools and your existing computer setup.
As you’ll soon see, it’s easy to get started making web pages—you will be able to create simple pages by the time you’re done reading this book. From there, you can continue adding to your bag of tricks and find your particular niche in web design. In the meantime, try answering the questions in EXERCISE 1-1.
TEST YOURSELF
Each chapter in this book ends with a few questions that you can answer to see if you picked up the important bits of information. Answers appear in Appendix A.
1. Match these web professionals with the final product they might be responsible for producing:
a. Graphic designer _____ HTML and CSS documents
b. Production department _____ PHP scripts
c. User experience designer _____ “Look and feel” deliverables
d. Backend programmer _____ Storyboards
2. What does the W3C do?
3. Match the web technology with its appropriate task:
a. HTML _____ Checks a form field for a valid entry
b. CSS _____ Creates a custom server-side web application
c. JavaScript _____ Identifies text as a second-level heading
d. Ruby _____ Makes all second-level headings blue
4. What is the difference between frontend and backend web development?
5. What does an FTP tool do and how do you get one?
EXERCISE 1-1. Taking stock
Now that you’re taking that first step in learning web design, it might be a good time to take stock of your assets and goals. Using the lists in this chapter as a general guide, try jotting down answers to the following questions:
• What are your web design goals? To become a professional web designer? To make personal websites only?
• Which aspects of web design interest you the most?
• What current skills do you have that will be useful in creating web pages?
• Which skills will you need to brush up on?
• Which hardware and software tools do you already have for web design?
• Which tools do you need to buy? Which tools would you like to buy eventually?
Part I. Getting Started
What You’ve Learned
20
IN tHIS CHaPtEr
An explanation of the web as it relates to the internet
The role of the server
The role of the browser
URLs and their components
The anatomy of a web page
I got started in web design in early 1993—pretty close to the start of the web itself. That’s a quarter of a century ago (gasp!), but I still distinctly remember the first time I looked at a web page. It was difficult to tell where the informa- tion was coming from and how it all worked.
This chapter sorts out the pieces and introduces some basic terminology. We’ll start with the big picture and work down to specifics.
THE INTERNET VERSUS THE WEB
No, it’s not a battle to the death, just an opportunity to point out the distinction between two words that are increasingly being used interchangeably.
The internet is an international network of connected computers. No com- pany owns the internet; it is a cooperative effort governed by a system of standards and rules. The purpose of connecting computers together, of course, is to share information. There are many ways information can be passed between computers, including email (POP3/IMAP/SMTP), file trans- fer (FTP), secure shell (SSH), and many more specialized modes upon which the internet is built. These standardized methods for transferring data or documents over a network are known as protocols.
The web (originally called the World Wide Web, thus the “www” in site addresses) is just one of the ways information can be shared over the internet. It is unique in that it allows documents to be linked to one another via hyper- text links—thus forming a huge “web” of connected information. The web uses a protocol called HTTP (HyperText Transfer Protocol). That acronym should look familiar because it is the first four letters of nearly all website addresses, as we’ll discuss in an upcoming section.
HOW THE WEB WORKS
2 CHAPTER
The web is a subset of the internet. It is just one of many ways information can be transferred over networked computers.
21
A Brief History of the Web The web was born in a particle physics laboratory (CERN) in Geneva, Switzerland, in 1989. There a computer specialist named Tim Berners-Lee first proposed a system of information management that used a “hypertext” process to link related documents over a network. He and his partner, Robert Cailliau, created a prototype and released it for review. For the first several years, web pages were text-only. It’s difficult to believe that in 1992, the world had only about 50 web servers, total.
The real boost to the web’s popularity came in 1992 when the first graphical browser (NCSA Mosaic) was introduced, and the web broke out of the realm of scientific research into mass media. The ongoing development of web technologies is overseen by the World Wide Web Consortium (W3C).
If you want to dig deeper into the web’s history, check out the W3C’s History Archives at www.w3.org/History.html. FUN FACT: If you look at that page, you’ll see a July 1993 entry for the first “WWW Wizards Workshop.” Although I did not attend that meeting, I did design the commemorative t-shirt!
SERVING UP YOUR INFORMATION
Let’s talk more about the computers that make up the internet. Because they “serve up” documents upon request, these computers are known as servers. More accurately, the server is the software (not the computer itself) that allows the computer to communicate with other computers; however, it is common to use the word “server” to refer to the computer as well. The role of server software is to wait for a request for information, and then retrieve and send that information back as quickly as possible.
There’s nothing special about the computers themselves…picture anything from a high-powered Unix machine to a humble personal computer. It’s the server software that makes it all happen. In order for a computer to be part of the web, it must be running special web server software that allows it to handle HyperText Transfer Protocol transactions. Web servers are also called HTTP servers.
There are many server software options out there, but the two most popu- lar are Apache (open source software) and Microsoft Internet Information Services (IIS). Apache is freely available for Unix-based computers and comes installed on Macs running macOS. There is a Windows version as well. Microsoft IIS is part of Microsoft’s family of server solutions.
Every computer and device (router, smartphone, car, etc.) connected to the internet is assigned a unique numeric IP address (“IP” stands for “Internet Protocol”). For example, as I write this, the computer that hosts oreilly.com has the IP address 199.27.145.64. All those numbers can be dizzying, so fortu- nately, the Domain Name System (DNS) was developed to allow us to refer to
t E r M I N O LO GY
Open Source Open source software is developed as a collaborative effort with the intent to make its source code available to other programmers for use and modification. Open source programs are usually free to use.
Part I. Getting Started
Serving Up Your Information
22
http://www.w3.org/History.html
that server by its domain name, “oreilly.com”, as well. The numeric IP address is useful for computer software, while the domain name is more accessible to humans. Matching the text domain names to their respective numeric IP addresses is the job of a separate DNS server. If you think of an IP address as a telephone number, the DNS server would be the phonebook.
It is possible to configure your web server so that more than one domain name is mapped to a single IP address, allowing several sites to share a single server.
A WORD ABOUT BROWSERS
We now know that the server does the servin’, but what about the other half of the equation? The software that does the requesting is called the client. People use desktop browsers, mobile browsers, and other assistive technolo- gies (such as screen readers) as clients to access documents on the web. The server returns the documents for the browser (also referred to as the user agent in technical circles) to display.
The requests and responses are handled via the HTTP protocol, mentioned earlier. Although we’ve been talking about “documents,” HTTP can be used to transfer images, movies, audio files, data, scripts, and all the other web resources that commonly make up websites and applications.
It is common to think of a browser as a window on a computer monitor with a web page displayed in it. These are known as graphical browsers or desktop browsers and for a long time, they were the only web-viewing game in town. The most popular desktop browsers as of this writing include Edge and Internet Explorer for Windows, Chrome, Firefox, and Safari, with Opera and Vivaldi bringing up the rear.
These days, however, more than half of web traffic comes from mobile brows- ers on smartphones and tablets such as Safari on iOS, Android and Chrome browsers on Android devices, Opera Mini, and a myriad of other default and installable mobile browsers (see en.wikipedia.org/wiki/Mobile_browser for a complete list). Navigating the web on a touch screen is the new normal.
It is also important to keep alternative web experiences in mind. Users with impaired sight may be listening to a web page read by a screen reader (or simply make their text extremely large). Users with limited mobility may use assistive technology such as joysticks or voice commands to access links and enter content. The sites we build must be accessible and usable for all users, regardless of their browsing experiences.
The web is also finding its way onto smart TVs and gaming systems, where users access our pages with TV remotes or Xbox controllers. You never know where the web will pop up next!
t E r M I N O LO GY
Server-Side and Client-Side Often in web design, you’ll hear references to “client-side” or “server-side” applications. These terms are used to indicate which machine is doing the processing. Client-side applications run on the user’s machine (also referred to as the frontend), while server-side applications and functions use the processing power of the server computer (the backend).
t E r M I N O LO GY
Intranets and Extranets When you think of a website, you generally assume that it is accessible to anyone surfing the web. However, many organizations take advantage of the awesome information sharing and gathering power of websites to exchange information just within their own network. These special web-based networks are called intranets. They are created and function like ordinary websites, but they use special security devices (called firewalls) that prevent the outside world from seeing them. Intranets have lots of uses, such as sharing human resource information or providing access to inventory databases.
An extranet is like an intranet, but it allows access to select users outside of the organization. For example, a manufacturing company may provide its customers with passwords that allow them to check the status of their orders in the company’s orders database. Passwords determine which slice of the company’s information is accessible.
2. How the Web Works
A Word About Browsers
23
https://en.wikipedia.org/wiki/Mobile_browser
The reality is that pages may look and perform differently from browser to browser. This is due to varying support for web technologies, varying device capabilities, and the users’ ability to set their own browsing preferences. It is the most challenging aspect of designing and developing for our medium.
WEB PAGE ADDRESSES (URLS)
Every page and resource on the web has its own special address called a URL, which stands for Uniform Resource Locator. It’s nearly impossible to get through a day without seeing a URL (pronounced “U-R-L,” not “erl”) plas- tered on the side of a bus, printed on a business card, or broadcast on a televi- sion commercial. Web addresses are fully integrated into modern vernacular.
Some URLs are short and sweet. Others may look like crazy strings of char- acters separated by dots (periods) and slashes, but each part has a specific purpose. Let’s pick one apart.
The Parts of a URL A complete URL is generally made up of three components: the protocol, the site name, and the absolute path to the document or resource, as shown in FIGURE 2-1.
Browser Rendering Engines The program that is responsible for converting HTML and CSS into what you see rendered on the screen is called a rendering engine (also browser engine or layout engine). Browsers that you use on desktop computers and mobile devices are made up of rendering engines as well as other code used for their own user interfaces and functionality. Although I talk a lot about which browsers support particular functions in this book, I’m
technically referring to the browser’s rendering engine. Various browsers often share a rendering engine; for example, the Blink engine powers Chrome, Opera, and a variety of Android browsers. TABLE 2-1 lists the rendering engines used by the most popular web browsers today. For more information, search Wikipedia.com for “Comparison of web browser engines” and “Comparison of web browsers.”
TABLE 2-1. Current browsers and their rendering engines
Browser Rendering engine
Chrome 28+ Blink (forked from WebKit)
Firefox (all) Gecko (except Firefox for iOS, which uses WebKit)
Safari and Safari iOS (all) WebKit
Internet Explorer 4–11 Trident
MS Edge (all) EdgeHTML (forked from Trident)
Opera 15+ Blink (forked from WebKit)
Part I. Getting Started
Web Page Addresses (URLs)
24
http:// www.example.com /2018/samples/first.html
Hostname Domain name
Protocol1 Name of site2 Absolute path3
Directory path Document
FIGURE 2-1. The parts of a URL.
1 http://
The first thing the URL does is to define the protocol that will be used for that particular transaction. The letters “HTTP” let the server know to use HyperText Transfer Protocol, or get into “web mode.” You may also see a URL begin with https://, which I explain in the “HTTPS, The Secure Web Protocol” sidebar.
2 www.example.com
The next portion of the URL identifies the website by its domain name. In this example, the domain name is “example.com.” The “www.” part at the beginning is the particular hostname at that domain. The hostname “www” has become a convention, but is not a rule. In fact, sometimes the hostname may be omitted. There can be more than one website at a domain (called subdomains). For example, there might also be “develop- ment.example.com,” “clients.example.com,” and so on.
3 /2018/samples/first.html
This is the absolute path through directories on the server to the request- ed HTML document, first.html. The words separated by slashes are the directory names, starting with the root directory of the host (as indicated by the initial /). Because the internet originally comprised computers run- ning the Unix operating system, our current way of doing things still fol- lows Unix rules and conventions, hence the / separating directory names.
To sum it up, the URL in FIGURE 2-1 says it would like to use the HTTP proto- col to connect to a web server on the internet called “www.example.com” and to request the document first.html, located in the samples directory, which is in the 2018 directory.
Simplified URLs Obviously, not every URL you see is so lengthy. To get to O’Reilly’s site, you’d expect to type oreilly.com instead of http://www.oreilly.com/index.html. Here’s why that works.
URL Versus URI The W3C and the development community are moving away from the term URL (Uniform Resource Locator) and toward the more generic and technically accurate URI (Uniform Resource Identifier). On the street and even on the job, however, you’re still likely to hear URL.
Here’s the skinny on URL versus URI: a URL is one type of a URI that identifies the resource by its location (the L in URL) on the network. The other type of URI is a URN that identifies the resource by name or namespace (the N in URN).
Because it is more familiar, I will be sticking with URL throughout this book. Just know that URLs are a subset of URIs, and the terms are often used interchangeably.
If you like to geek out on this kind of thing, I refer you to the URI Wikipedia entry: en.wikipedia.org/wiki/ Uniform_Resource_Identifier.
2. How the Web Works
Web Page Addresses (URLs)
25
Skipping the protocol Because nearly all web pages use the HyperText Transfer Protocol, the http:// part is often just implied. This is the case when site names are advertised in print or on TV, as a way to keep the URL easy to remember.
Additionally, browsers are programmed to add http:// automatically as a convenience to save you some keystrokes. It may seem like you’re leaving it out, but it is being sent to the server behind the scenes.
When we begin using URLs to create hyperlinks in HTML documents in Chapter 6, Adding Links, you’ll learn that it is necessary to include the protocol when making a link to a web page on another server.
Pointing to default files Many addresses do not include a filename, but simply point to a directory, like these:
http://www.oreilly.com http://www.jendesign.com/resume/
When a server receives a request for a directory name rather than a specific file, it looks in that directory for a default document, typically named index. html. So when someone types the previous URLs into his browser, what he’ll actually see is this:
http://www.oreilly.com/index.html http://www.jendesign.com/resume/index.html
The name of the default file (also referred to as the index file) may vary, and depends on how the server is configured. In these examples, it is named index. html, but some servers use the filename default.htm. If your site uses server- side programming to generate pages, the index file might be named index.php or Default.aspx. Just check with your server administrator or the tech support department at your hosting service to make sure you give your default file the proper name.
Another thing to notice is that in the first example, the original URL did not have a trailing slash to indicate it was a directory. If the slash is omitted, the server checks to see if the request is a file or a directory. If it is a directory, the server asks the browser to send the request again with a slash. In the end, the slash is included for directories, even if it isn’t included the first time it is entered (see Performance Tip).