How To Design and Write A Web Pages
How To Design and Write A Web Pages
How To Design and Write A Web Pages
Recent Titles in Writing Today How to Write about the Media Today Ral Damacio Tovares and Alla V. Tovares How to Write Persuasively Today Carolyn Davis
Writing Today
Copyright 2011 by Karl Stolley All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, except for the inclusion of brief quotations in a review, without prior permission in writing from the publisher. Library of Congress Cataloging-in-Publication Data Stolley, Karl. How to design and write web pages today / Karl Stolley. p. cm. (Writing today) Includes bibliographical references and index. ISBN 978-0-313-38038-9 (hardback) ISBN 978-0-313-38039-6 (ebook) 1. Web sitesDesign. I. Title. II. Series. TK5105.888.S76 2011 006.7dc22 2010051317 ISBN: 978-0-313-38038-9 EISBN: 978-0-313-38039-6 15 14 13 12 11 1 2 3 4 5
This book is also available on the World Wide Web as an eBook. Visit www.abc-clio.com for details. Greenwood An Imprint of ABC-CLIO, LLC ABC-CLIO, LLC 130 Cremona Drive, P.O. Box 1911 Santa Barbara, California 93116-1911 This book is printed on acid-free paper Manufactured in the United States of America
To Patricia Sullivan
CONTENTS
Series Foreword Preface Acknowledgments PART I. WHAT AM I WRITING? Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Why Write for the Web? Reading the Web Creating Web Content Standards-Based Web Pages Preparing to Write and Design PART II. ISSUES AND CHALLENGES Chapter 6 Chapter 7 Chapter 8 Accessibility Usability Sustainability
ix xi xxi
3 13 25 33 43
57 69 81
viii
CONTENTS
PART III. STRATEGIES FOR SUCCESS Chapter 9 Structured Content: XHTML Overview 91 103 121 133 147 159 177 189 205 225 235
Chapter 10 Presentation and Design: CSS Overview Chapter 11 Rapid Prototyping Chapter 12 Writing with Source in a Text Editor Chapter 13 Page Metadata Chapter 14 Page Branding Chapter 15 Navigation Chapter 16 Text Content Chapter 17 Page Layout Chapter 18 Multimedia Content Chapter 19 Performance and Interaction PART IV. PROBLEMS AND SOLUTIONS Chapter 20 Site Architecture Chapter 21 Reusing and Dynamically Generating Content Chapter 22 Dynamic Sites in WordPress Chapter 23 Going Live Chapter 24 Tracking Visitors, Sharing Content Resources for the Future Glossary Index
SERIES FOREWORD
Writing is an essential skill. Students need to write well for their coursework. Business people need to express goals and strategies clearly and effectively to staff and clients. Grant writers need to target their proposals to their funding sources. Corporate communications professionals need to convey essential information to shareholders, the media, and other interested parties. There are many different types of writing, and many particular situations in which writing is fundamental to success. The guides in this series help students, professionals, and general readers write effectively for a range of audiences and purposes. Some books in the series cover topics of wide interest, such as how to design and write Web pages and how to write persuasively. Others look more closely at particular topics, such as how to write about the media. Each book in the series begins with an overview of the types of writing common to a practice or profession. This is followed by a study of the issues and challenges central to that type of writing. Each book then looks at general strategies for successfully addressing those issues, and it presents examples of specic problems and corresponding solutions. Finally, each volume closes with a bibliography of print and electronic resources for further consultation. Concise and accessible, the books in this series offer a wealth of practical information for anyone who needs to write well. Students at
SERIES FOREWORD
all levels will nd the advice presented helpful in writing papers; business professionals will value the practical guidance offered by these handbooks; and anyone who needs to express a complaint, opinion, question, or idea will welcome the methods conveyed in these texts.
PREFACE
The arts are made great, not by those who are without scruple in boasting about them, but by those who are able to discover all of the resources which each art affords. Isocrates, ca. 390 B.C.1 First, a disclaimer. This book will not teach you everything you need to know about writing and designing for the Web. No single book can. But what this book will do is provide you with just about everything you need in order to learn everything you need to know to write and design for the Web. The Web is unique among all forms of digital communication, in that top to bottom, the Web is language. Language that you can learn to read and write. From the visual designs of your pages, to the structure of your pages, to the Web servers that deliver your pages to readers, the Web is nothing but language. And those who wish to be rhetorically successful on the Web must command the languages and accompanying concepts behind the languages in order to best communicate with the unique audience for any given Web site. Contrary to how software companies market their products, the ability to write and design and communicate effectively on the Web is not determined by how much money you have, the software you can afford to buy, or the whims of a particular computer company.
xii
PREFACE
It is determined by how well you can command the languages of the Web to best communicate with the audience you are hoping to reach through your Web site and other forms of digital identity that you establish on the Web.
PREFACE
xiii
the worlds most popular Web server,3 to better deliver your content across the Web.
xiv
PREFACE
you to work differently with Web technologies, but about deepening your understanding of them to change how you think, learn, and talk about them, too. One thing you will notice about this book is that it does not shy away from the technical knowledge and vocabulary surrounding Web writing and design. There is a very good reason for this: more than any other form of digital writing, writing for the Web is a community activity. People work together to establish new practices and technologies for communicating on the Web. Two examples of that are open-source blogging software such as WordPress4 and the Microformats.org5 community, which is helping to make the information on Web pages easier to share and use away from the Web. But in order to join or even simply benet from the knowledge of any communitywhether photographers, football fans, carpenters, knitters, poker players, medical doctors, or Web designersyou have to know or be willing to learn the words that that community uses in addition to engaging in photography, carpentry, poker, or whatever activity the community is known for. Think for a moment about your hobbies, your college major, or classes you have taken: in each of those areas, you have acquired specialized knowledge and technical words to talk about different subjects in ways that are more sophisticated than someone outside of your hobby, college major, or classroom. Writing for the Web is no different: its terms may be unfamiliar and technical, but you know technical terms from other domains already. Web design and development is just another domain of knowledge. This book does not expect that you know these terms already, but it will help you learn them, search the Web for them, and use them to talk and collaborate with others on Web projects.
PREFACE
xv
However, this book does not teach Web writing according to one particular piece of software, and it outright discourages the use of whatyou-see-is-what-you-get (WYSIWYG) software packages, such as Microsoft FrontPage or Adobe Dreamweaver, because WYSIWYGs fail Web writers at three important things: First, WYSIWYGs fail at supporting revisions to pages. Writing must always be revised. It never comes out perfectly the rst time. And on the Web, things other than writing will also need revision: for example, your design might work in one Web browser, but not another. Web page creation is relatively easy; Web page revision is notunless you understand how you wrote the page initially. Second, software packages for creating Web pages fail to prepare you for other, more advanced forms of Web production. If you want, for example, to build a custom template for a WordPress site, you have to understand how to write with the Webs languages; there is no WYSIWYG system for WordPress templates. (True, you can download a WordPress template of someone elses design, but that diminishes the rhetorical impact your site would otherwise have if it featured your own unique design.) Third, if you learn how to create Web pages only according to one piece of software, then your abilities will be dependent on the continued existence of that software. And even if the softwares brand name continues to exist, the company behind it may radically restructure the softwares interface and features and youll nd yourself a beginner all over again. It was exactly those three problems that I encountered in my own Web design work that led me to develop new methods to teach my students to design Web pages the way I write about in this book. That said, my philosophy toward learning digital communication technologies is simple: learn them right and learn them well the rst time. If you know or are willing to learn the languages of the Web XHTML, CSS, JavaScriptthen you will always know how to build Web pages, regardless of what software you have available. Learning
xvi
PREFACE
the languages of the Web, coupled with the concepts for thinking and talking about them, will make it even easier for you to pick up other languages, or changes to existing ones, in the future. The only tools you absolutely have to have to build a Web site are a Web-friendly text editor, a search engine, and a good Web browser, all of which are available as free downloads. There are suggestions for each later in this book. A Web-friendly text editor is where you do your writing; it is the view of your Web page where you do your work. But not only are you writing the content of a page that someone else will read, you are also writing, in the Webs languages, about your content. And when you learn to write in the Webs languages, you can then begin to shape not just what but how someone will read your pages. You may also nd, as I have, that writing about your content in XHTML and CSS even helps you rene the content itself to better reach your audience. A search engine is your portal to XHTML, CSS, and JavaScript references and guides (so you dont have to memorize everything about those languages) and your means of discovering the many communities of people who are devoted to the art of writing and designing for the Web. A chapter toward the end of this book lists some trustworthy references and helpful communities to get you started. And nally, a good Web browserI recommend Mozilla Firefoxis the last essential piece of technology you need. As a solid development browser, Firefox will provide an initial real-world view of your Web pages and, with the help of some add-ons (also free), will help you to rene your pages construction and design before you test them on as many other browsers and devices as you can. (However, the approaches to Web writing and design suggested in this book will help you to minimize differences from browser to browser.) I have also created a Rapid Prototyping Kit (RPK) that is available as a free download from this books companion Web site. The RPK will help you start building your site and its pages with condence, while
PREFACE
xvii
still giving you plenty of exibility to tailor your site for the specic needs of your audience.
xviii
PREFACE
material that you post to your site easier to share with others on Facebook and elsewhere, so as to broaden your identity across the Web. And nally, Resources for the Future provides a topical list of additional print and digital publications to consult to extend your knowledge of writing and designing for the Web. It also lists links to galleries of Web design to peruse for inspiration, and some suggested Google search terms to help you discover even more resources. Because this book is about Web design, it will necessarily cover many technical topics and terms. A glossary is provided to help you manage the books many technical words and concepts.
PREFACE
xix
xx
PREFACE
NOTES
1. Isocrates, Against the Sophists, in vol. 2 of Isocrates, trans. G. Nordlin, Loeb Classical Library (Cambridge: Harvard University Press, 1929), 169. 2. Aristotle, Rhetoric, in The Rhetoric and Poetics of Aristotle, trans. W. R. Roberts (New York: The Modern Library, 1984). 3. September 2009 Web Server Survey, Netcraft.com (September 23, 2009), http://news.netcraft.com/archives/2009/09/23/september_2009_web_ server_survey.html 4. WordPress.org, http://wordpress.org 5. Microformats.org, http://microformats.org 6. Paul Rand, Design, Form, and Chaos (New Haven, CT: Yale University Press, 1993), xii.
ACKNOWLEDGMENTS
This book is largely the product of teaching students who put an incredible amount of trust in the unorthodox thing I encourage them to do: abandon the constraints of software and learn to write the Web by hand; not as programmers, but as writers and designers. I am still grateful, many years later, to the rst group of undergraduate students to whom I taught standards-based Web design in a multimedia writing courseand to David Blakesley, who encouraged me to teach the course while I was a graduate student at Purdue University. And I am also grateful to the graduate students in technical communication and information architecture at Illinois Institute of Technology, who expressed enthusiasm and encouragement while reading the draft form of this book in our Web design class. In particular, I offer special thanks to Laurie Riley, Kelly Schaefer, and April Wedekind, who offered thoughtful responses to this books earliest draft chapters, and to Erica Dekker and Susan Mallgrave for their comments and corrections when the book was nearly complete. I also thank my graduate assistant, Freddrick Logan, for his work on this project. Many thanks to the Mozilla Foundation for its policy allowing writers to reproduce screen captures of the Firefox Web browser and to Frank Hecker for answering my questions about the Mozilla Foundations policies. Thank you also to Chris Pederick (chrispederick.com) for creating and maintaining the Web Developer Add-on for Firefox and for permitting me to showcase it in screen shots throughout this
xxii
ACKNOWLEDGMENTS
book. Many thanks also to Don Ho for his work on Notepad++ and for likewise permitting me to use screen shots of Notepad++ to illustrate Web writing. I am grateful for the support of all of my colleagues at Illinois Institute of Technology in the Lewis Department of Humanities. And this book would not have taken the shape it has without my many colleagues and friends across the elds of rhetoric, computers and writing, and technical communication. Any list of names risks being incomplete, but you know who you are. See you on Facebook or Twitter. I express my sincere thanks to George Butler, my editor at Greenwood/ABC-CLIO, who approached me to write this book for Greenwoods Writing Today series and who was receptive to the idea of a book that would take a rhetorical, software-neutral approach to Web design. I am also grateful to Bill Hart-Davidson and Janice Walker, who served as the manuscripts reviewers, for their thoughtful criticisms and encouraging feedback. I am forever indebted to my mentor Patricia Sullivan, whose pioneering work in digital writing and rhetoric continues to inspire me to pursue the line of research that led to this book. More than that, Pat is a dear friend whose wisdom is matched only by her generosity and unwavering dedication to her students, past and present. Nancy DeJoy has my profound gratitude for her constant encouragement and friendship. More than a few of this books chapters were drafted in Nancys kitchen, where we both worked on our separate projects, punctuating periods of quiet with spirited conversation as we shared and responded to each others writing. I also thank my brother, Colin Stolley, who answered my questions about both computer science and the law and the intersection of the two and offered invaluable suggestions and guidance throughout this project. I reserve my deepest thanks and gratitude to my wife, Amy, for her love and her seemingly boundless capacity for patience and understanding as both a partner and a collaborator.
PAR T
WHAT AM I WRITING?
This section prepares you to begin writing on the Web. As with all other parts of this book, you will stand to benet most if you read with a computer nearby so you can try some things out and learn in a more hands-on way. On the Web, we write to be foundan idea the rst chapter explores in depth, along with simple things you can do to immediately begin establishing or improving your Web presence. Reading is the counterpart of writing, and the second chapter suggests approaches and tools for reading the Web like a writer and designer. The remainder of this section involves preparing content for your Web site, including a chapter with a brief history of how Web pages were made in the past, and how they are made now according to what are called Web standards, which guide the design advice in this book. Finally, this section concludes with a chapter about setting up your own custom environment to write, design, and test your pages. As we will see, building great Web pages is more than what any one piece of software can do, and some of the best software for building Web pages is available for free on the Webthanks to many thousands of volunteers devoting their time and effort to building quality free and opensource software.
CHAP TE R
WRITING TO BE FOUND
Whether you are building a Web site for yourself, or for a business or organization, there is no more important reason to write for the Web than to build a stable, custom online identity that you control. It is no secret that schools and employers search the Web for their applicants names as part of their admissions or hiring process. And yet for many people, the results that show up in Google and other Web search results are far from ideal in conveying an accurate, well-rounded identity. Do a Google search for yourself right now (also known as ego surfing). Be sure and try variations on your name. If your name is Catherine, for example, but you sometimes go by Cathy, search for both (with your last name, of course!). You might even want to search for alternate spellings of your name: in Catherines case, Katherine and Kathy. When I ego surf, I also routinely search Google and Googles Blog Search for combinations such as: Karl Stolley "Karl Stolley" (with quotation marks, to search rst and last names appearing in sequence)
"Stolley, Karl" (with quotes, to search last name rst, as some pages list names that way) What kinds of results appear for you? People with common names, like Jim Smith, may see results for dozens, even hundreds of so-called Googlegngers: people with the same name, but vastly different (and sometimes morally suspect) interests and backgrounds. People with multiple Googlegngers will want to whittle down the results. Try adding to your name the city where you live, your employer, job title, occupation or professional eld, or perhaps the school you attend. For example, I will search for these variations: Dr Stolley technical communication Professor Stolley Illinois Institute of
Technology
Even for people with uncommon names, the search results may not be encouraging. There may be no results for your name at all. And if there are results, they may be scattered, confusing, and downright goofy: perhaps you were quoted in a story for a school or local newspaper. You might nd yourself on a missing classmates page in the alumni area of a college or university Web site. Or perhaps you used your real name when replying to an online forum about troubles with the type of car you drive. You might even nd that some well-meaning relative tagged you in an unattering photograph on Flickr. In all of those cases, the results do not point positively to one page or another that fully and accurately represents you. As you look at the list appearing with your name, ask yourself: What would a potential employer, a potential college or graduate school think of these results? If youre working on a Web site for a business or a club, and searching the Web for its name, ask yourself what potential customers or members would think. Scattered, random results are frustrating. And if you have your own Web site already, it might be even more frustrating to discover that it does not appear as the number one ranking for your name search on Google, or even in the top ten. The methods for writing and designing Web pages presented in this book will help you to establish your Web presence and likely improve your sites ranking in Google and other search engines.
or less. You can post to Twitter via its Web site, special add-ons to your Web browser, or stand-alone clients like TweetDeck.2 It is also possible to post to your Twitter account from just about any kind of mobile phone. In Twitter-speak, to post is to tweet. Registration on Twitter is quick and free (see the Controlling Your Name sidebar for help choosing a Twitter username). But Twitter might seem ridiculous to those who havent tried it: What possible good can 140-character microblog posts do for establishing an online
identity? The answer lies in many little lessons that Twitter teaches about Web writing in general: Be interesting. Yes, you can announce to Twitter that youre eating a sandwich or walking the dog. But thats not terribly interesting. Its much better to post your perspective on issues you care about, or share the thinking side of your professional work or even your hobbies. Frequent activity is essential to any Web presence. Nothing is more important to Web audiences than fresh content and signs of life, or what I call living content. Pages that appear not to have been updated for some time are suspect to Web audiences and might seem to have been abandoned. With Twitters 140-character limit, it is easy to update often and without the extended efforts required of full-on blogs or Web sites. Get to the point, because no one has time. Brevity is key to Web writing. No one has time, so maximum rhetorical impact has to be achieved in few words. Frequent use of Twitter will help you learn the art of minimal expression. Write once, publish (just about) everywhere and often. Some people use their Twitter account to update their Facebook status, and many others use Twitters RSS feeds to publish their latest Tweets to their own custom Web sites. Updating Twitter, in other words, causes multiple sites to update simultaneously for these individuals. A single act of writing keeps multiple online presences fresh with living content. There is more to connecting on the Web than linking to pages. An essential part of Twitter is following others tweets and, by posting interesting things, others following yours. Building networks of connections with other humans, and not just their Web pages, is an essential part of being found on the Web and establishing an identity that is not an island unto itself. In addition to Twitter, you might also consider establishing a Facebook account.3 Both Twitter and Facebook will make it easy for you to announce your new or redesigned Web site when the time is right.
But Twitter will allow you to start establishing a presence in Google search results immediately (provided you do not elect to protect your Tweets). Beyond microblogging, there are other general categories of Web sites where you can begin to establish your online presence by registering and using an account: Social bookmarking sites, such as Diigo, let you share bookmarks to things you nd on the Web Social networking sites, such as LinkedIn, MySpace, in addition to Twitter and Facebook Photo sharing sites, such as Picasa and Flickr Video sharing sites, such as YouTube and Viddler
DO UNTO OTHERS . . .
Simply stated, Dont let your Web site or social media account (Twitter, Flickr, MySpace) come to shape the identities of others who have not established their own Web presence. Once you begin to write and design for the Web, you may nd yourself referring to friends and colleagues by name. I have a simple rule about this: never refer by full name to someone who does not have a Web site, or who is not a public gure or published author. If someone blogs or Tweets under an alias, refer to her by her alias, not her full name. It is also good practice to avoid referring to conicts or sensitive situations in your family, school, or workplace, even if you withhold names. My own preference is to avoid referring to family, school, or workplace entirely unless its the kind of news that someone could be given an award for and that has been announced elsewhere rst. At the same time, if someone does have a Web site and you are positively referring to him by name, be sure to link to his site. This helps strengthen the other persons Web presence; with luck, and your own kind treatment of others, they will link back and do the same for you.
10
and other social Web sites allow you to do this through direct follow or friend relationships. There are less structured ways of connecting with others, too. Just as you searched for your own name in Google and other search engines above, you can search for the names of your friends, peers, and colleagues, too. Some of them may have Web sites and blogs. Finding new people is as simple as searching for interests, professions, or careers and the words personal Web site or blog. Blogs, in particular, present terric opportunities for connecting with others, particularly through comment functions available in most blogging software. Comments allow readers to add reactions and indicate interest in others writing, and on many blogs, to share the address to their own Web sites. If you dont yet have a Web site that you control, you can always share your Twitter address when you comment on a blog post. When you do have your own URL, add it to your Twitter prole. Readers intrigued by your comment on someones blog, and interested by your Tweets, could easily follow the link in your prole to your Web site. And once you have your own Web site, particularly if it includes a blog component (see Chapter 22), regularly linking to others sites or blog posts and portfolio items helps you to establish even more connections with other people. (Chapter 24 will talk about server statistics and other means for getting a sense of who is visiting and linking to your site.)
NEXT STEPS
On the Web, we write to be found. Twitter is a great rst step to establishing an online presence, as are other social media sites that allow you to connect with other people. But such sites are just a start; a custom Web site is still a crucial component of your online identity and presence. Once you have a custom Web site, your many other online presencesTwitter, Facebook, Diigocan be used for lifestreaming:4 announcing new content, site changes, and so on at your Web site, to audiences you share a closer connection with already. The next chapter will address the important rhetorical skill of reading the Web, which will help you see how others have worked to establish an identity for themselves.
11
NOTES
1. Twitter, http://twitter.com 2. TweetDeck, http://tweetdeck.com 3. Facebook, http://www.facebook.com 4. Paul McFedries, Lifestreaming, Word Spy, http://www.wordspy.com/ words/lifestreaming.asp
CHAP TE R
14
A WEB-READING TOOLKIT
To read the Web (and later to test your own designs) in as many ways as possible, install some or all of the following free browsers and tools: All Users (Windows, Mac, and Linux) Mozilla Firefox (http://www.mozilla.com/refox) Chris Pedericks Web Developer Add-on for Firefox (https://addons .mozilla.org/refox/addon/60) Google Chrome (http://www.google.com/chrome/) Opera browser (http://www.opera.com/) Windows Users Internet Explorer 8 or above (IE) Microsoft Expression Web SuperPreview (For testing multiple versions of IE) (http://expression.microsoft.com/en-us/dd565874 .aspx) Safari for Windows (http://www.apple.com/safari/download/) Lynx for Windows (http://home.pacic.net.sg/~kenneth kwok/lynx/) Mac Users Lynx for OS X (http://www.apple.com/downloads/macosx/ unix _ open _ source/lynxtextwebbrowser.html) If you cannot install software, try a Google search for browser emulator to nd sites that offer approximations of the views provided by different browsers.
15
Try making yourself use a different browser every day for a week or so. Try alternating between, say, Mozilla Firefox, Google Chrome, Opera, and Internet Explorer, particularly with sites you visit every day. You may even nd that different browsers are better for different activities. On Windows computers, I prefer Chrome for most of my daily use: reading my Gmail account, posting to Twitter, and managing my Web sites. On Mac, I prefer Safari (whose WebKit engine is also used in Chrome). And on all computers, I rely on Firefox for Web design and development. Because Firefox is open source, people have built many excellent Web design add-ons for it, such as Chris Pedericks Web Developer Add-on thats used throughout this book.
16
to different fonts (see Chapter 10). The Trident engine, which tends to be the most unpredictable, is used in Internet Explorer and AOL Explorer. If you regularly change up your browser use, you will see that some Web sites take a hostile approach to readers who arent using a specic browser. Its not uncommon to encounter Web sites ranging from banking sites to university and corporate intranet/Web portals that demand that visitors use a specic Web browser. People attempting to view the site with the wrong browser may be greeted with nothing more than a message stating, Your browser is not supported. Gee, thanks. The approaches to Web design in this book emphasize designing in a browser-neutral way. The technology and standards exist for browserneutral design (see Chapter 4), but it is an eye-opening experience to see just how many Web sites are still designed to work only on specic browsers.
17
supports high school athletes from underprivileged backgrounds, it might design its site to look something like ESPN.com. Such a design choice would help to put the organization in the context of sports and sport Web sites. (Whether that design choice would increase donations is another matter. An overly lavish Web site design could conceivably hurt a charitable organization if it appears that donations are all spent on Web design!) When reading a Web site, challenge yourself to identify its purpose and context. Sometimes the purpose is expressed in the sites content: writing, images, and other media. Design also plays a role in conveying purpose and context, as does the performance of the site. The next sections offer lists of questions to consider for reading according to content, design, and performance.
18
19
content of the siteor to contradict it? Does the design affect how credible you believe its author/designer to be?
20
21
As you move from one page to another in the same site, does it take a long time for the page to be redrawn, or does the design appear to be almost static, with only the content changing?
Reading by Breaking
In addition to looking at sites in modern, graphical browsers like Firefox, Safari, and Opera, it is instructive to view sites in the Lynx browser or a Lynx emulator, which provide text-only views of a site. Viewing a site as text only will give you a sense of what will be read aloud to lowvision readers, and in what order, when they visit a site. Lynx will also reveal what some mobile phone browsers may render. For a more nuanced way of looking at a site with certain features disabled, install the Web Developer Add-on for Firefox. With it, you can choose to disable any JavaScript on a site, disable the display of images, and even disable the pages CSS. Breaking a page in those ways gives you more than a view similar to users without JavaScript, image display, or CSS. It also gives you hints as to how a page has been made: if you turn off CSS, for example, and the pages design barely changes, it means the pages author used outdated, HTML-based methods for designing the pages (see Figures 2.1 and 2.2). With CSS off, there should be no design other than default browser styles (see Figures 2.3 and 2.4). If JavaScript is disabled and content disappears, the sites author probably uses JavaScript to generate content rather than placing the content directly in the HTML where it belongs. Text: Do the sites headings and lists still appear to be headings and lists in default styling in Lynx or with CSS disabled? Are all contextual links still clickable and usable in the absence of JavaScript? Does the text refer to any missing photographic or media content in a way that makes the site confusing or unusable? Photographs: Does alternate text appear for missing photographs? Is the text a meaningful alternative, one that would be useful to someone without the ability to view the sites images? Video and Media: Is there any alternate content offered for video and other media, particularly when the site is viewed
Figure 2.1. An old course Web site that I created with HTML-based design. Figure 2.2 has CSS disabled, but the design is basically the same.
Figure 2.2. The same design as Figure 2.1, but with CSS disabled. Because the design used outdated HTML properties, it is virtually identical when CSS is disabled.
22
Figure 2.3 A course Web site that I created with CSS-based design, about a year after the one in Figures 2.1 and 2.2. Figure 2.4 has CSS disabled, leaving no traces of the design.
Figure 2.4. The same design as Figure 2.3, but with CSS disabled. All that is left is the default browser stylingevidence of a modern, CSS-based design.
23
24
in Lynx? Does disabling JavaScript cause Flash movies to no longer display/load? Are there links to download the media for viewing/hearing outside of the browser? Controls: If JavaScript is disabled, is it still possible to navigate the site? Do any page functions cease to operate in terms of printing, sharing, and so on? Are image galleries still browseable? If images are disabled, do you see alternate text for buttons or other controls? Layout and Design: Even in Lynx, are headings, paragraphs, and lists clear? Or does text run together or seem to be spaced in strange ways? When disabling CSS, is a page still useful in terms of the order the content appears in? Is the page useful/ navigable in mobile devices, or when using the Small-Screen Rendering in the Web Developer Add-on (found under the Miscellaneous menu)?
NEXT STEPS
There is no one best way to write a sites content, create its design, or ensure its performance. But reading a variety of Web sitesthe ones you use everyday, plus some of the gallery sites suggested at the end of this bookwill help you to develop a sense of the range of approaches to building Web sites. Reading a variety of sites for design and performance will also help you get inspired to start working on your own design. But content is still the most important aspect of a site. In the next chapter, we will look at how you can begin gathering and creating content for your Web site while you begin to learn the Web writing and design technologies covered in Strategies for Success.
NOTES
1. Wikipedia, List of Web Browsers, http://en.wikipedia.org/wiki/ List_of_web_browsers 2. Mozilla Developer Center, Gecko, https://developer.mozilla.org/en/ gecko 3. The WebKit Open Source Project, http://webkit.org/
CHAP TE R
WRITTEN CONTENT
The written content of your site is crucial to your site being found and accessible. Even if you are a photographer or a visual artist, search engines index and allow people to search the writing of your page. Image searches arent image searches at all, but rather searches on captions, descriptions, and other contextual information.2 Written content can also be read aloud or presented as Braille, and therefore made accessible to readers requiring assistive technologies. That is why all media elementsimage, audio, and videoshould have text equivalents.
26
Web audiences typically expect a Web sites written content to be direct and to the point, with plenty of headings and lists to make the content navigable. Posting to Twitter is a great way to learn to write more directly: How expressive can you be in 140 characters or less? In addition to a direct style, written content should be rich with keywords that you think your intended audience might plug in to search engines. Writing teachers always teach students to write with thick, rich description. That approach to writing pays big dividends on the Web: it helps your ranking in Web searches on key terms, while also helping you to better communicate with your readers. Although I prefer to compose most Web content directly in my text editor, there is nothing wrong with composing your text (but not your XHTML or CSS) in a word processor. (Just be sure that you use the Unicode character set, UTF-8, in your XHTML; see Chapter 9.)
27
Keep in mind the following if you decide to write in your word processor: Do not waste time doing a lot of formatting in the word processor. Youll be pasting your text directly into XHTML, which has no visual properties of its own, so any formatting is going to be lost anyway. An empty line of space between headings, paragraphs, and lists is more than enough formatting. Separate headings and list items with extra lines of empty space by using the Enter key. Lines of white space will be useful when you go to add your XHTML markup later. If the visual formatting in the word processor helps you write, use it. But be careful of copying bulleted lists from word processors, though, as the bullet itself often gets translated to an asterisk (*) when its pasted into a text-only environment, like a Web editor. Paste any word processor text into the code view, if you are using a WYSIWYG Web editor. Some WYSIWYGs try to be helpful by retaining markup to the text copied from word processor documents, but that markup can be a real pain to edit later. Do not import images into your word processor documents. Images must be treated in a particular way for the Web (see Chapter 18). However, if you know of an image you want to accompany your text, you might make a note of it in your word processor le for future reference. Do not post word processor documents on your site. If you are creating a portfolio or thinking of posting forms for a small business Web site, you might be tempted to post and link directly to a word processor document. In most cases, it is better to publish word processor documents in Portable Document Format (PDF), and then post the PDF to your Web site. Mac users can create PDFs using the built-in features of the OS X operating system; Windows users need either the full Adobe Acrobat software, or an open-source alternative like PDFCreator.3 (See Chapter 6 for more information about accessible Web le formats.) Regardless of where you write, prefer direct sentences and paragraphs and make good use of headings and lists. Headings and lists help
28
readers navigate a page quickly to get a sense of its content, or help them nd the specic content returned by a Google search.
CONTENT IMAGES
Content images, including photographs, scans, and illustrations, can help a Web sites content spring to life. Like all media content, images must be prepared for the Web in particular ways. Preparing images for the Web is a compromise between the size, in bytes, of an image le and its quality. Image quality is a matter of the
ESSENTIAL EQUIPMENT
Capturing images and perhaps audio and video is key to developing original media content for your Web site. Here is a list of essential equipment that you should consider purchasing. You may even discover that your school or public library has some of this equipment available for your use: A digital camera. The quality that even cheap digital cameras provide is often more than enough for Web purposes. Look for cameras that have a high optical zoom (3 or above; digital zoom is not terribly useful), a rechargeable battery, and removable memory cards. But in a pinch, even a cell phone camera or a Web cam can get you started. A scanner. Good scanners are available for around $100, especially if they arent bundled with a printer/fax machine. For Web purposes, a low-quality scanner is more than enough for scanning in artwork and printed matter. If you only have a few things to scan, try to nd a scanner at your school or library. A digital video camera. Many digital still cameras come with some sort of limited video capability. There are also inexpensive video cameras available, some of which plug directly into your computer with an onboard USB connection. A good quality microphone. Computers are very good at capturing audio that sounds great, provided you have a quality microphone. Stores that cater to musicians usually have a better selection of microphones available than electronics retailers. For recording the human voice, look into purchasing a condenser microphone that comes with its own power source, usually an onboard battery (just remember to power it off when youre done recording).
29
dimensions (in pixels) of an image and in the case of JPEG (.jpg) images, a matter of image compression, which removes some data from an image to reduce its le size. Always keep copies of your original photographs and scans. Photographs and images that come off of a digital camera or scanner are almost never Web ready; they must be resized, compressed, and otherwise edited rst. But keep all of the original image les, in case you ever need to re-edit them. Here are some basic approaches to preparing your images for the Web, which should be saved in either JPEG or PNG format (see Chapter 18 for more about loading media onto your pages): Learn to use the crop and resize functions in your image editor. Most image editors have lters for all sorts of visual effects, and all of them have controls for adjusting the contrast, brightness, and other visual properties of images. But to start, the two most important features you should learn are cropping, which helps you cut off the edges of a photograph, and resizing (sometimes called resampling), which reduces the dimensions of an image to Web-appropriate sizes. Images for the Web display according to their actual pixel dimensions, so coordinate those with your layout. Most image editors have dots per inch (DPI) or pixels per inch (PPI) settings alongside their resize function. But Web images display independently of any DPI or PPI setting: 72dpi or 96dpi are both common settings for Web images, but the setting only has an effect when the image is printed. What matters in the screen display of Web images is actual pixel dimensions: an 800-pixel-wide by 600-pixel-tall image will display in a Web browser as 800 by 600 regardless of whether the les DPI is set to 300 or even 1. Different photographs will look best at different compression rates. When you go to save your image, most image editors offer some type of slider that varies the compression of JPEG images. High compression means lighter les and faster downloads, but at the expense of image quality. And image quality varies under the same compression rate: a picture of the sky, which has a large area of roughly the same color, will get ugly, rectangular splotches at high compression rates. Images
30
with high contrast details, like black letters on a white street sign, will get little sparklies and other compression artifacts around the high-contrast area. Get to know your image editor and the way it compresses different images. You can nd examples of image treatment at the books companion Web site, http://sustainablewebdesign.com/book/.
Audio Content
Audio content destined for the Web should be prepared in MP3 format; while MP3 is a proprietary le format, it is also widely used in all sorts of desktop and portable digital audio players. Preparing MP3 audio les is a complex matter, but here are some basic settings that you should use: output your les as 8-bit stereo sound. Perhaps the most important setting on MP3 les is their bit rate; for voice applications, 64 kilobits per second (kbs) will provide adequate sound quality, although 128 kbs often sounds noticeably better. However, the higher the bit rate, the larger the sound le. Be sure also to record and prepare your MP3 audio at a 44.1 kHz sample rate, simply because that sample rate is supported by Flash and other players, and there are no savings in le size with MP3s when you lower the sample rate. For a technical but all-in-one discussion of this, see http://www.blogarithms.com/index.php/mp3secrets/.
Video Content
Video content is the most complicated material to prepare for the Web. In addition to shooting and editing your video, it is essential that sound syncs with motion. For most purposes, posting video on YouTube is an ideal solution (Chapter 18 lists other, similar sites for video hosting). First, the videos are stored and transferred from YouTubes servers, not
31
yours. This keeps you from expending large amounts of bandwidth, or the amount of data your server can serve at any one time, on your own server. YouTube also does a generally outstanding job of behind-thescenes compression and resizing of video, though be sure to consult their documentation on making and posting videos.4 Finally, maintaining a YouTube account is yet another way to establish your presence on the Web. Because YouTube allows you to set up a prole that can include a link to your Web site, you may be able to attract YouTube users to your site. The only problem with YouTube is that the code it provides for embedding videos on your Web site does not adhere to Web standards. (See Chapter 18s discussion of JavaScript and the SWFObject 2.0, which addresses this issue.) For testing purposes, though, there is nothing wrong with cutting and pasting the YouTube code. You can swap it out with the JavaScript-based solution before your site goes live, or as a future improvement.
NEXT STEPS
The work of writing and designing your pages depends on the real content of your site. Now that you have some idea of how to prepare for the Web the content you should be gathering and writing, its time to look at what a Web page is, the history of how pages have been made, and why standards for Web writing and design are so important.
NOTES
1. Lorem ipsum, http://www.lipsum.com/ 2. Google Web Search Help, Getting Started: About Google Images, http://www.google.com/support/websearch/bin/answer.py?answer=112512 3. PDFCreator, http://sourceforge.net/projects/pdfcreator/ 4. YouTube.com, Making and Optimizing Your Videos, http://www.you tube.com/t/howto_makevideo
CHAP TE R
34
spoken and written language: This is a standard sentence. Standard this sentence is not (unless Yoda you are). If you had to install a different kind of electrical outlet for every device you own, learn different trafc-signal patterns from city to city, or learn to speak a different language for each individual human in your neighborhood, youd probably be a hermit whod never leave the solitary, candlelit comforts of home.
35
36
see the instructions that cause any given page to display as it does. And not only can you view open source, but you can edit it, tooalthough your changes will only appear if the page is yours and you have access to the server where it is stored.
Figure 4.1. Source from an old Web page of the authors. Dont stare at it too long; but take heart: Web pages no longer have to be this complicated.
37
38
VALIDATE THIS!
One interesting benet to designing your pages according to Web standards is that there is an external, nonvisual method of assessing just how compliant your Web pages are with the standards. This method is known as validation, which involves using a validator to check the code of your Web pages against the rules for the languages you have used, including XHTML and CSS. There are two validators that you should use throughout your projects development: The W3C Markup Validation Service (http://validator.w3.org/). This service, offered by the W3C, allows you to validate your HTML either by inputting a URL, uploading an HTML le, or even copying and pasting your HTML directly into the validator. The W3C CSS Validation Service (http://jigsaw.w3.org/cssvalidator/). As with the Markup Validation Service, the CSS Validation Service gives you multiple options for checking your CSS. As you are writing and designing, if something strange or unexpected happens when viewing your Web pages in a browser, the rst thing you should do is validate your XHTML (even if you suspect a problem with your CSS). If the XHTML is valid, then validate the CSS. You will learn more about working with the validators in the Strategies for Success portion of this book.
WaSP changed all of that through years of tireless activism. With the stable releases of Internet Explorer 6 (IE6, in 2001) and Netscape Navigator 6 (NN6, in 2002), both leading browsers provided viable support for W3C standards, including XHTML and CSS, among other standards. Web designers could begin to design and write Web pages to the recommendations of the W3C. That is not to say that IE6 and NN6 implemented Web standards precisely. (Even now, no browser follows all W3C standards to the letter, though some browsers are more standards compliant than others.) But by 2002, both browsers followed the W3Cs specications for HTML and CSS closely enough that browser targeting and browser-specic pages should have become a thing of the past. Should have. Unfortunately, despite improvements in Web browsers standards compliance, some Web designers continued to rely on oldfashioned practices (see the sidebar What You Wont Learn in This Book for examples).
39
40
HTML5
There is a new specication for HTML in development, called HTML5.* It is intended to be the successor to HTML 4.01. What is interesting about HTML5 is that its specication originated in 2004 outside of the W3C by a group that dubbed itself the Web Hypertext Application Technology Working Group (or WHATWG). Although it is possible to write pages in HTML5, the specication is still largely in development.** Learning XHTML 1.0, as this book advocates, will prepare you to pick up HTML5 later, if you decide to use it rather than XHTML 1.0. There are also HTML5 resources on this books companion site, http://sustain ablewebdesign.com/book/.
*W3C, HTML5: A Vocabulary and Associated APIs for HTML and XHTML, http://www.w3.org/ TR/html5/ **WHATWG, FAQ, http://wiki.whatwg.org/wiki/FAQ
supported standard Web languages in existence. But despite being called a language, XML is actually a standard set of rules for creating other languages (called applications, in XML-speak) that enable people and computer applications to share structured content with one another. The most important XML application for Web purposes is XHTML 1.0, which appeared as a W3C recommendation in January 2000.6 XHTML is the HTML language rewritten according to XMLs rules. In many ways, HTML and XHTML are the same language. But XMLs rules are much simpler and more consistent than SGMLs, the language from which the original HTML was created. This book promotes the use of XHTML (specically, XHTML 1.0 Strict) and only refers to HTML in historical senses (although see the sidebar HTML5). In addition to drawing upon XMLs simplicity and consistency, XHTML also reects the spirit of XML, which is to provide structured information, free from any visual presentation. Old practices in writing HTML resulted in messes like:
<FONT face="Arial, Helvetica, sans-serif" color=#cc6600 size=7> The World Wide Web </FONT>
41
XHTML is used to do nothing more than provide meaningful structure to all of a pages text content and any media elements such as images, audio, and video. The Strategies for Success portion of this book offers guidance in building structured content in XHTML.
One thing that makes CSS a better alternative to HTML-based design is that CSS can completely change the look of a site without a designer having to rewrite the sites XHTML. The most famous demonstration of this is the CSS Zen Garden.7 The Zen Garden is a showcase of CSS-based designs, all of which use the exact same XHTML. Have a look; youll be amazed. CSS also allows you to control the look of your entire site from one CSS le. Changes to that lefor example, changing headings to appear in purple rather than redare instantly reected across your entire site. To redesign a site involves nothing more than changing the CSS le. This also makes sites load faster: the CSS instructions only have to be downloaded once, which helps Web browsers build your pages in the browser window very quickly. And CSS can change more than just the visual design of a page on screen. CSS can also be used to specify how a page looks when printed, removing needless items like site navigation or making visible detailed copyright information. CSS can be used for assistive technologies, too.
42
Special CSS properties exist for changing how a Web page sounds when it is read aloud. That is why CSS can be said to handle presentation, which includes the more specic term visual design. However, in this book, CSS is limited primarily to visual design for screen and print. For more on CSS, see Chapter 10.
NEXT STEPS
Now that you have some sense of where Web standards came from and why they are necessary for Web designers to know, the next chapter prepares you to write and design by helping you set up a custom writing, design, and publishing environment that supports writing and designing with Web standards.
NOTES
1. The Web Standards Project, http://webstandards.org 2. Tim Berners-Lee with Mark Fischetti, Competition and Consensus, Weaving the Web: The Original Design and Ultimate Destiny of the World Wide Web (New York: HarperBusiness, 2000), 10321. 3. Berners-Lee, Weaving the Web, 9193. 4. Jeffrey Zeldman, Designing with Web Standards, 2nd ed. (Berkeley, CA: New Riders, 2007), 5357. 5. W3C, Extensible Markup Language (XML) 1.0, http://www.w3.org/ TR/1998/REC-xml-19980210 6. W3C, XHTML 1.0 The Extensible HyperText Markup Language (Second Edition): A Reformulation of HTML 4 in XML 1.0, http://www .w3.org/TR/xhtml1/ 7. CSS Zen Garden, The Beauty in CSS Design, http://www.csszengar den.com/
CHAP TE R
44
PORTABLE APPLICATIONS
If you work with different computers at home and at work, or even if you have no computer of your own but rely on school or public libraries for computer access, portable applications enable you to use the same applications wherever you go. Portable applications are software programs that you can run on a USB drive (sometimes called a thumb or jump drive) or even an iPod. A 2GB or larger USB drive provides sufcient space to install your own set of applications and take them wherever you go. There are numerous Web sites that list portable applications that you can download, but these two sites offer extensive lists: For Windows, PortableApps.com (http://portableapps.com/) lets you download an entire suite of applications, or via the Applications page, download individual applications. PortableApps.com lists portable versions of just about every kind of software you need to do Web development: image editors, audio editors, text editors, and so on. For Mac, the best collection of portable applications that I have found is housed at FreeSMUG.org (http://www.freesmug.org/ portableapps/). (Note that if you switch between Mac and Windows computers, you might have to keep two copies of each application, one for each operating system.)
Syntax highlighting, or functionality that recognizes XHTML tags and other language features, and colors them according to their purpose. Different editors highlight XHTML and CSS in different ways, using different colors. The colors do not matter, but the coloring does: it makes XHTML and CSS easier to read, and much easier to nd errors in your code. Line numbering, which displays a line number next to each line in your XHTML and CSS (note that the numbers are not part of your XHTML and CSS les, though). This feature is very useful for correcting errors discovered in XHTML and CSS validators, which report errors by the line they appear on. Function reference/completion is a feature not available in all Web editors, but it suggests XHTML tags and CSS properties as you type or on a particular key command. Note, however,
45
that some Web editors with this feature may suggest nonstandard tags, so always have a Web-available language reference with you as you work (see Chapters 9, 10, and 19). A built-in File Transfer Protocol (FTP) or Secure File Transfer Protocol (SFTP) client makes it easier to move les from your computer or USB drive to your hosted Web space. Not all editors have an FTP client built in, but there are plenty of stand-alone FTP/SFTP clients available. With those features in mind, here are the free and open-source Web editors and FTP/SFTP clients I recommend to my students: Windows: Notepad++ makes writing XHTML and CSS very simple through syntax highlighting and other features. It has a built-in FTP client, but if your Web host requires SFTP, try WinSCP.4 If you plan to use the lunch hour at work to do Web development and/or if you want to use the program on a public computer in a library or a cyber cafe, Notepad++ can be run from your USB drive (see the Portable Applications sidebar). Mac OS X: TextWrangler is a great free editor, also with a built-in FTP client.5 A solid stand-alone FTP/SFTP program for Mac is CyberDuck.6 You are not limited to these, of course; there are hundreds more that a Google search for Web text editor and SFTP client will turn up. Just keep in mind the features listed above if you choose to use a different one.
46
extensions by default. So rather than seeing myle.htm listed in your folder, youll see only myle. You might also think youre saving a le as myle.htm, when in reality its been saved as myle.htm.txt! Do a Google search for show le extensions and the name of your operating system to learn how to reveal le extensions on your computer. Use only lowercase letters, numbers, and the hyphen. Most Web servers are case-sensitive, meaning that MyFile.htm is different from myle.htm. By always using lowercase letters, you and your audience never have to guess the capitalization on your sites URLs: there is none. Numbers are safe, as are hyphens. Do not use any other symbols or punctuation in your le names, as almost all of them (?, &, +, =, etc.) have special meaning to Web servers. Never use spaces in le and folder names. All operating systems allow spaces in le and folder names. But spaces cause trouble on the Web. A le saved as research interests. htm on a computer translates to research%20inter ests.htm in a Web browser. Instead of spaces, use hyphens:
research-interests.htm
Make le and folder names as short, direct, and memorable as possible. resume.htm is preferable to my-completeresume.htm or even my-resume.htm. You want to be able to tell someone, My resume is at myname dot com slash resume dot htm. Never use new, old, current, or other references to time or versions in le names. new-photos.htm will one day not be new. Use numbers with one or more leading zeros. Serialized le or folder names should begin with one leading zero (e.g., photo01.jpg, photo02.jpg) if you expect less than 100 items, or two leading zeros (e.g., photo001.jpg) if you expect less than 1,000 items. That helps organize the listing of serialized les in FTP clients and other le and folder views on your computer. Use .htm or .html le extension, but not both. Consistency is key to staying sane. I recommend using .htm on XHTML
47
ESSENTIAL FOLDERS
Keeping organized is essential to managing the many components of a Web site. The Rapid Prototyping Kit (see Chapter 11) uses these folders: css: A folder for storing all of your sites .css les. gfx: A folder inside of css, which is for storing all of the graphics for your site. By graphics, I mean images that are part of the design and referred to in the CSS. Photographs and other content images are stored in the media folder (below). js: A folder for storing all of the JavaScript les for your site. media: A folder for storing all of the media content on your site. The media folder contains ve different folders to help you keep your content organized, specically: audio: A folder for storing any audio content for your site. img: A folder for storing any photographs and other content images. The folder is called img as a reminder to you that these are images used with the XHTML <img /> (image) tag (see Chapter 18). pdf: A folder for storing any PDF les that your sites pages link to. swf: A folder for storing any published Flash movies that appear on your site. video: A folder for storing any video content that appears on your site.
les, but if you opt to use .html, always use .html. CSS les should all end in .css; JavaScript les should all end in .js. Again, set your operating system to show le extensions. Be sure to follow those rules for your XHTML and CSS les and your image, audio, and other media les, too. One shorthand summary: name les and folders as though you have no shift key or space bar.
48
Figure 5.1. Pedericks Web Developer Add-on lets you do things like edit CSS and see your changes instantly in the browser.
standards support, particularly for CSS3, that Macs Safari has, but it is free of the odd bugs that Microsofts Internet Explorer is notorious for (see QuirksMode.org7). And because Firefox is an open-source Web browser, a large developer community has developed all kinds of add-ons for Firefox. Many of these add-ons, like Chris Pedericks Web Developer Add-on, are tailored specically for Web development (see Figure 5.1). Note that using Firefox as a baseline development browser does not mean a return to designing for one specic browser. Rather, Firefox is the Goldilocks choice: not too advanced, not too buggy, but just right. Web development is a complex activity; limiting early development to one good browser is a wise choice. My experience has been that Safari will handle everything that Firefox will, in terms of CSS and DOM Scripting. Internet Explorers oddities are easily and sustainably xed using conditional comments to load a few additional CSS styles (see Chapter 23).
49
50
There are numerous domain name registration sites on the Web. I will not recommend one particular site over another, but do consider the following cautions when choosing a company to register your domain name:
51
Never pay much more than $10 a year for each of the .com, .org, or .net top-level domains (TLDs) that you buyand do buy all three of those TLDs together, if you can afford it. Never opt in to any promises of search engine optimization or other services that registration (or hosting) companies may offer. Register your domain, and thats it. Buy your domain name from one company, and your hosting from another. Many Web hosting companies invite you to register your domain name with them or to transfer registration for a domain you purchased elsewhere. My suggestion is to avoid this; buying your domain name from your Web host might make it difcult for you to move to other hosts in the future. Keep those two transactions separate, and you will never have to worry about losing your domain name to a bad hosting company. There are also thousands of Web hosting companies to choose from. Here are some general things to know as you select a Web host: Hosting generally runs between $5 and $20 a month. Most reputable hosting will be somewhere within that range. Beware of hosting thats cheaper than $5 a month; the old rule of You get what you pay for applies. Large or unlimited storage is not necessarily a good thing. A terabyte of storage might sound like a good thing, but it invites abuse from people posting huge music or photo collections, which may slow down the same server your site is on. Unlimited storage might also be used to deect customers attention from less attractive features of the hosting service. Generally, anywhere from 1 to 10 gigabytes (GB) of storage is more than sufcient. Unlimited transfer or trafc can also be a bad thing. Again, it invites abusive customers; 500GB of transfer a month is plenty for most sitesand nd out in advance how much the company charges for overage fees beyond your allotted data transfer. Most Web hosts showcase Web sites that are hosted on their servers. Look through those sites: note how fast they load in particular. While
52
slow-loading pages on one or two of the sites may not necessarily be the hosts fault, if all of their featured sites load slowly, look for hosting elsewhere. So what features do you look for? Here are some baseline hosting features for the long-term growth of your site: Linux or Unix-based servers; this information can be hard to determine for some hosts, so look hard. A Google search for the hosting companys name and operating system can often help you discover this information. MySQL 5.1 database. Be sure you can have at least three databases. These will be useful if you decide to run blogging or wiki software. Secure Shell access (also known as SSH). Some hosts enable this by default, but most require you to ask for it. Shell access lets you access your server to run certain commands and is important to have for setting up certain blogging, wiki, or content management system software. SFTP access. Hosts generally offer FTP access, but FTP transmits your password in the clear (without encryption), which can be a security risk to your site. SFTP stands for Secure FTP, and is often found with hosts that also grant SSH access. PHP 5. Watch out for hosts that are still only offering PHP 4; good hosts will offer PHP 4 and 5, but encourage you to use 5. The Apache Web server with support for per-directory conguration les using .htaccess. This feature lets you customize certain aspects of how your Web site and Web server function. Depending on your needs, you might also consider whether a host offers: Log les and server statistics; these can help you see whos linking to your site, or what search terms they used to nd it (see Chapter 24). Email accounts (most hosts offer this).
53
Email lists (essential for business and organizational Web sites). Secure socket layer (SSL), which is essential for e-commerce. Hosting multiple domain names; this will allow you to host your own Web site and perhaps another, such as a community organization you belong to.
NEXT STEPS
Now that you have an idea of the basic tools and services required for Web writing and design, know that youll discover your own preferences as you write and design your pages. The great thing about standardsbased Web design is that switching text editors, baseline development browsers, and even Web hosts will not harm your site (although you may have to relearn some things). Finding a setup that works for you and that youre comfortable with is essential. At the same time, give yourself time to learn all about the setup you choose. No one understands these things immediately. In the next few chapters, we will look at accessibility, usability, and sustainabilitya trio of important concerns that everyone writing and designing for the Web needs to consider.
NOTES
1. Chris Pederick, Web Developer Add-on for Firefox, https://addons .mozilla.org/en-US/refox/addon/60 2. Notepad++, http://notepad-plus.sourceforge.net/ 3. XAMPP, http://www.apachefriends.org/en/xampp.html 4. WinSCP, http://winscp.net/ 5. TextWrangler, http://www.barebones.com/products/TextWrangler/ 6. CyberDuck, http://cyberduck.ch/ 7. QuirksMode.org, http://www.quirksmode.org/ 8. Net Applications, Net Market Share, Browser Market Share, http:// marketshare.hitslink.com/browser-market-share.aspx?qprid=0&qptimeframe=Y 9. IE NetRenderer, http://ipinfo.info/netrenderer/
PAR T
II
56
touchpads/touchscreens, and mice. Sites must also be accessible to search engines, or your content will never be found or indexed for others to nd in a Web search. Usability. Usability is often associated with usability testing, where trained experts observe targeted users interacting with a Web site. But usability can also inform your approach to designing for site performance and user expectations. A site that takes forever to load or otherwise performs poorly makes its use difcult or impossible. If user expectations are not met, as when site navigation has confusing or even misleading buttons, users may become frustrated with the site and leave. Beyond simply ensuring that users can complete a task, usability helps you earn the good will and attention of your audience. But usability is not function alone: people like things that function well, but they like fun and pleasing things even moreWeb sites included. Sustainability. A site that is accessible and usable today must continue to be so. Digital technologies change quickly and without much notice, it is true. Still, there are certain design practices and choices that will better future-proof your Web site. Sustainability is also about the access and use of a site as the site grows, or scales. Certain writing and design choices may be accessible and usable on a site of only ve pages. But what if the site grows to 50 pages? Or 500? Each of those issues will be treated in the next three chapters. Refer to them often as you work on the design of your site, and as you work through some of the technical matters in the chapters in Strategies for Success.
CHAP TE R
Accessibility
Some Web designers dislike the word accessibility, because it can easily be misunderstood as forcing unacceptable limits on artistic creativity or even promoting a bleeding-heart political agenda. But this chapter reframes accessibility in a much broader scope and shows that accessibility can actually encourage creativity, not limit it. We will also see that accessibility is not beholden to any political agenda, but rather a rhetorical one: accessibility maximizes the potential size and range of a Web sites audience.
WHAT IS ACCESSIBILITY?
Accessibility is a Web standard, similar to XHTML and CSS (see Chapter 4). The World Wide Web Consortium has a group dedicated to accessibility: the Web Accessibility Initiative (WAI). The WAIs introduction to accessibility declares that Web accessibility means that people with disabilities can use the Web.1 Thats a very limited denition. And if a Web designer believes that disabled people do not use the Web, or that disabled people represent such a small minority of users that their needs arent worth taking the time to design for, odds are that designer will skip over accessibility matters entirely. But a remarkable study from 2004 found that some 57 percent of working-age adults in the United States benet from accessible technology, and that this percentage is all but certain to increase as the population ages.2 The fact is that 57 percent is no minority. Accessible design addresses the needs of disabled users, yes, but as a product of serving the needs of all people. The accessibility and
58
ACCESSIBILITY STANDARDS
There are three key resources for accessibility on the Web. Although primarily oriented toward addressing the needs of disabled people, it is worth your time to explore each of these: Web Accessibility Initiative (WAI) (http://www.w3.org/WAI/): The WAI, an organization that publishes a wealth of information on accessibility, is one of the primary advocates for Web accessibility. Web Content Accessibility Guidelines (WCAG) (http://www.w3.org/ WCAG/): Released as W3C Recommendation WCAG 2.0 in December 2008, WCAG is a very technical document. Because of this, the design community has reacted quite negatively to it, as in Joe Clarks article To Hell with WCAG 2.* Section 508 (http://www.section508.gov/): Section 508 refers to a 1998 amendment to the Rehabilitation Act of 1973, which was meant to end discrimination based on physical ability within the federal government and federally funded agencies. Section 508 is specically about information technologies, such as government Web sites. While Section 508 is not applied as law to nongovernmental Web sites, the Section 508 guidelines and technical standards (http://www.access-board.gov/sec508/ standards.htm) are still useful to consider when building an accessible Web site.
*Joe Clark, To Hell with WCAG 2, A List Apart: For People Who Make Web Sites, No. 217 (May 23, 2006), http://www.alistapart.com/articles/tohellwithwcag2
accessible design techniques presented below aim to make sites available to all users, without special adaptation or modication and regardless of their computer equipment or physical ability.3 Accessible design accounts for the full range of conditions of user access. User access is determined both by human conditions, such as physical or sensory abilities, as well as technological conditions, such as computer equipment, network connection speeds, and so on. In certain cases, human and technological conditions are closely related, as when a particular human condition (such as low vision) necessitates a technological condition in the form of an assistive technology (such as a screen reader).
ACCESSIBILITY
59
But in almost all cases, conditions of accessboth human and technologicalare nonnegotiable. They are states. Web designers, no matter how talented, cannot leverage the technologies of the Web to transform the computer someone uses to read the Web, any more than they can change someones physical or sensory abilities. Access conditions are states that design should account for, but cannot alter.
60
designed Web site, the sidewalk would actually change its properties, automatically, to best accommodate the needs of each pedestrian. So while you may encounter advice from accessibility advocates who suggest creating separate, specialized versions of pages that are geared for particular devices, for printing, or for people with specic disabilities, standards-based Web design enables you to create a single page that anticipates and addresses the access conditions of all users.
ACCESSIBILITY
61
there are only three that work reliably in all Web browsers. JPEG and PNG images are generally preferable to GIFs, as GIFs are limited to 256 colors. (See Chapters 3 and 18 for additional information about image formats.) All content images should have alternative text in XHTML, too. And that is it for the conservative list, as far as content goes. Whats missing from this list? Plenty, including some very popular formats, such as word processor documents and PDFs, sound and video les, and Adobe Flash. Its not that your site cannot use those formats; countless Web sites do. However, anything beyond XHTML text and the three common image formats must be treated carefully. The challenge is that no content other than XHTML text and common image formats can be viewed directly in most browsers without the use of a plugin (e.g., the Flash Player) or other third-party application (e.g., Adobe Acrobat Reader). If a mobile phone does not have a word processor application on it, it will be unable to access word processor documents posted to the Web. The same problem affects PDFs, Flash, and audio and video les, too: without the appropriate application, or without a certain level of sight or hearing, people may not be able to access those formats. If you must post PDFs or word processor documents, be sure to alert users which links point to those kinds of les, perhaps by placing the le format in parentheses. You should also include links to download the Flash Player, Acrobat Reader, or other software required to view your les. Remember, though, not all users will be able to install software. So keep your crucial content in XHTML.
62
might force you to scrap design components that represent a signicant investment of time and effort. Particularly among Web designers who work with DOM scripting (see Chapter 19), there are two related concepts that are instructive for building from accessibility, and not back toward it: progressive enhancement and its user counterpart, graceful degradation.7 Progressive enhancement is the design approach: each component of a Web page builds on another: rather than putting design instructions directly in XHTML, for example, you build a really solid structure for your content in XHTML. Then the design component, written in CSS and kept in its own separate .css le, is layered by capable Web browsers on top of the XHTML. Graceful degradation is the corresponding user experience: all browsers read XHTML; most read CSS. Users with CSSenabled browsers have a progressively enhanced experience. But users with XHTML-only browsers are not punished by the presence of CSS if the site degrades to XHTML-only presentation. Note that an XHTML-only device, such as a screen reader, will not provide what seems to a user to be a degraded experience. Rather, graceful degradation enables an optimal experience for an XHTML-only device. Let me share an example of graceful degradation: After redesigning a major online writing lab Web site, I received an email from a blind student who wished to express her gratitude that the new site contained no design images. (The old site had many, and made it difcult for her to use.) In truth, there were actually plenty of design images on the site; the difference was that the new site presented them in such a way that they would improve the experience of users who can benet from a graphical display, without punishing users who cannot. That the student thought there were no design images on the site is exactly what she should have thought (content images, however, are a different matter; users must be made aware of those if they cannot view them). Figures 6.1 and 6.2 show how a design-image rich site (Figure 16.1) degrades gracefully for text-only display.
Figure 6.1. A yer the author created to promote a course. The page makes extensive use of CSS background images.
Figure 6.2. The same page as Figure 6.1, but viewed in Lynx. All of the content is there, with no intrusion by the graphics in 6.1.
64
Progressive enhancement, then, is how you should design: start with a solid foundation of content marked up in XHTML; add design in CSS; and nally, add any advanced functionality that your site needs using unobtrusive JavaScript (see Chapter 19). Progressive enhancement returns us to Postels Law from the last section: Be conservative in what you do, be liberal in what you allow others to do. In many ways, what I advocate in terms of accessible design is a very conservative approach: it is not about using some trendy method to design pages. But it is a very liberal approach in its view of what users should be able to do: let them view the page in whatever browser or assistive technology they have available. Once you have designed with progressive enhancement in mind, graceful degradation is what you should test for: view your site in Lynx, or in Firefox with the Web Developer Add-on, which allows you to disable images, CSS, JavaScript, or any combination thereof. (We saw those accessibility tests in action in Chapter 2; apply them to your own site, too.) If the site content and controls are still accessible under all of those conditions, congratulations: your site gracefully degrades, and your visitors should have few problems accessing it. Continue to test your site over time, and consider providing your email address or another means for visitors to contact you in case they encounter accessibility problems.
In-Page Navigation
For people who routinely browse the Web on desktop and laptop computers, moving through the contents of a single Web page is usually a simple matter of using the scrollbars on the browser, the scrollwheel on a mouse, or in certain cases, the touch pad on a laptop.
ACCESSIBILITY
65
On certain devices, such as screen readers and some mobile phones, scrolling down long pages might be difcult or time-consuming. To account for this, its preferable to design sites that have a short accessible navigation area near the top of each page that allows users to jump to major sections of the page, such as the main content area or the site navigation. In the Rapid Prototyping Kit (RPK, see Chapter 11), the header area of the XHTML includes an unordered list with a class of accessibility. There are two links that allow a device to jump either to the page content or the site navigation. These accessible links save users with screen readers from having to listen to all of a pages content before they can access the navigation or, conversely, to jump to the content without having the navigation read aloud rst. In the RPK, the content area immediately follows the accessible navigation; given that, it might seem silly to have a Skip to Content link. However, the idea behind including it is to inspire condence in users, whether of assistive or mobile devices, that they can control their browsing experience and get right to the part of the page that they seek. For graphical browsers, CSS can be used to hide the accessible navigation from view, using a technique discussed in Chapter 14. Sites that use that technique enable assistive technologies to read aloud the contents of the accessible navigation, while keeping the page from being cluttered by another navigation element that would be unnecessary for people experiencing the page graphically on a desktop browser.
Accessibility Attributes
The most well-known accessibility attribute in HTML and XHTML is alt, which provides alternate text for content images loaded in the image tag, <img />. Your XHTML will not validate if you do not have an alt attribute on all of your images (attributes and other parts of XHTML are discussed in Chapter 9). However, alt text is supposed to be limited to 100 characters.8 Given the old clich says that a picture is worth a thousand words, well, you can see the issue here: 100 characters (not words) will not come close. (Thats 40 fewer characters than a Twitter post allows.) There are some different options to addressing the limitation of alt; the rst is the title attribute. It, too, is very limited in length; most browsers will display title attribute text as a tooltip, but some may limit
66
the text to 85 characters. There is another attribute, long description (longdescrip), which allows devices to follow a link to a complete Web page with a longer description. Maintaining separate pages of description for each of your images is not a very manageable solution, though, especially given that not all assistive devices support it. Chapter 18 suggests other ways to prepare images and other media with additional text for all users. The image tag is not the only XHTML tag with special accessibility attributes. There are two attributes that can be added to the anchor tags to assist users in activating page navigation and other important links: tabindex and accesskey. tabindex helps change the order in which links are activated by using the Tab key on the keyboard; my preference is to run the tab index on the navigation items, although arguments could be made in favor of eliminating this entirely. accesskey is an attribute that allows someone to use a keyboard combination to activate a particular link, usually in the navigation area. See the books companion Web site at http://sustainableweb design.com/book/ for examples of using those two attributes to increase the accessibility of your links and navigation.
Figure 6.3.
Figure 6.4. DOM Scripting makes the course site more accessible for lowvision visitors, but also aids in projecting content in the classroom. Notice the sidebar disappears in this mode.
68
and presented with examples at the books companion site, http:// sustainablewebdesign.com/book/.
NEXT STEPS
Accessibility and universal design form the foundation for a rhetorically effective Web site, but ensuring equitable access to a site is only the rst step. Designers and writers must also be concerned about how and under what conditions users use Web sites, too. In the next chapter, we will look at usability-driven design approaches for creating usable sites.
NOTES
1. W3C Web Accessibility Initiative, Introduction to Web Accessibility, http://www.w3.org/WAI/intro/accessibility.php 2. Microsoft PressPass, New Research Shows 57 Percent of Adult Computer Users Can Benet from Accessible Technology, http://www.microsoft .com/presspass/press/2004/feb04/02-02AdultUserBenetsPR.mspx 3. William Lidwell, Kritina Holden, and Jill Butler, Universal Principles of Design (Gloucester, MA: Rockport Publishers, 2003), 14. 4. The Center for Universal Design, Universal Design Principles, http:// www.design.ncsu.edu/cud/about_ud/udprincipleshtmlformat.html 5. Ironick, My History of the (Internet) Robustness Principle, Ironick: Contingency, Irony, and Solidarity (2005), http://ironick.typepad.com/ironick/ 2005/05/my_history_of_t.html 6. Information Sciences Institute, Internet Protocol (1979), http://www .postel.org/ien/txt/ien111.txt 7. Jeremy Keith, DOM Scripting: Web Design with JavaScript and the Document Object Model (Berkeley, CA: Friends of Ed/Apress, 2005), 8586. 8. W3C, HTML Test Suite for WCAG 2.0: Test 3Image Alt Text Is Short (2005), http://www.w3.org/WAI/GL/WCAG20/tests/test3.html
CHAP TE R
Usability
In the last chapter, we saw that accessibility is a matter of designing to account for states or conditions of user access. By contrast, usability is a matter of designing to account for user behaviors. But it is futile to design for usability if a site is inaccessible; usability builds on accessibility. For example, an architect might design the rooms of a building to be maximally usable to people in wheelchairs by making wide doorways and placing light switches lower on the wall. But if the only way to get into that building is by a staircase, all of the usability features in the individual rooms are essentially pointless. Access is about conditions. Usability is about conscious (and unconscious) actions that a user can or might take on a Web page or Web site. Examples of actions are users following links or navigation buttons to nd material on your site or even resizing a browser window to view other applications (like an email program) while looking at your site. However, the primary usability concerns of basic Web sites come down to ndability and waynding. Findability is a users ability to nd relevant information, whether by a result for your site in a search engine or through your sites navigation and contextual links. Waynding enables users to establish a sense of where they are in your site, and how to get to other areas, if necessary. To determine whether Web sites are usable involves usability testing, where usability specialists observe actual users interacting with a site. For individuals designing Web sites on their own, a formal, extended usability test may not be feasible. But as Steven Krug suggests,
70
testing your site on even one usera friend, a family memberis better than testing it on none;1 Jakob Nielsen notes that most serious site usability problems can be discovered by testing on ve users.2 (The end of the chapter will suggest ways for you to conduct your own mini usability tests.) Testing has its place. However, usability and usable design principles can inform how you write and design for the Web from the very earliest stages.
WHAT IS USABILITY?
Usability, in its most general sense, concerns an interfaces ease of use and methods for improving ease of use.3 The key questions usability experts ask is whether a design is easy for its intended users to use, and whether it does something useful or valuable for those users. But usability can also include emotional dimensions of a Web site. As usability and emotional design expert Donald Norman has observed, Usable designs are not necessarily enjoyable to use.4 Designers should aim to build a site that not only supports the easy accomplishment of a meaningful or valuable actioncommenting on a blog post, locating an informational page about a sitebut that makes the users experience of actions enjoyable. Users perceive designs that are beautiful or fun as being easier and faster to use, even if laboratory experiments reveal that a utilitarian design and an emotional design allow people to accomplish the same task in the same amount of time, or the same amount of effort.5
USABILITY
71
and a pure experience of this incredible Web site. These imaginary visitors will thoughtfully consider the sites craftsmanship, pausing to reect on the gorgeous photographs and stunning design choices. They will read the pure poetry of every single word, follow every link with deep interest and fascination, and basically spend as much time reading and thinking about the site as I spent writing and designing it. That never happens. But designing to that fantasy seems to happen a lot, judging by writers and designers who unselectively post tons of content and design poor navigation. Designers operating under that fantasy incorrectly assume that everything on the site will be found eventually, simply because they also assume their users will look at everything. To develop a more realistic picture of why users visit a site, what they do there and how, we can use a framework thats become popular in human-computer interaction, called activity theory.6 A basic component of activity theory is a exible, three-tiered hierarchy for thinking about user behaviors: At the top of the hierarchy is the users activity, which is always motivated by some objective (e.g., using the Web to nd the best price on a DVD, a chili recipe for dinner, or Professor Smiths ofce hours). Activities are carried out through the next level of the hierarchy, individual actions (searching on Google, exploring relevant results, reading pages on promising sites closely). Actions always have a particular goal: returning search results, clicking a link to explore a result, reading to decide whether the result is relevant. And individual actions themselves are often executed in part at the lowest level of the hierarchy, operations (typing, clicking, scrolling), which are normally carried out unconsciously. I have seen many beginning Web designers struggle with thinking about user activity. Most often, beginners are focused only on generating content. They may have a lot of really good ideas for the content they want to present, and some equally interesting ideas for their design and interfaces. But the points they sometimes forget to consider
72
are who their users are, what tasks those users will want to complete, and the broader activity that the users are engaged in that leads them to a particular site.
ACTIVITY: WHO ARE YOUR USERS? WHY ARE THEY AT YOUR SITE?
Users rarely show up at any Web site randomly, unless theyre using a site such as StumbleUpon, which exists to show users random but potentially interesting Web sites.7 And even if they do use such a site, they are still engaged in a specic activity (nding new and interesting Web sites) that might lead them to your site. Activities are dened by the broad objective that people are looking to accomplish when they visit your Web site. For example, an employer looking to hire qualied candidates in your area of expertise might turn up your resume in a Google search. A potential member of your club might enter your URL from a yer or postcard. A new customer might nd your site by following a link from an online review of your businesses. More randomly, you might have written a blog post about a problem and x for the mobile phone you own, which attracts the attention of someone else looking to x the same problem. In each of those cases, arriving at your Web site is a product of some broader activity: a job search, joining a club, hiring a business professional, or just trying to x a phone. To arrive at user activities unique to your site, though, its essential to develop a realistic list of groups of your sites potential visitors. The more specic the list of people, the better; itd be great if everyone in the world ocked to your Web site. But they wont. And it would be impossible to design a site that appeals to everyone while still meeting your own goals for the site. So everyone is not a useful category of users. For individual portfolio sites and blogs, more concrete groups of people might include employers, school admission committees, or even fellow hobbyists or colleagues in your profession/eld. For businesses, the list would include customers, shareholders, and even employees. Clubs and organizations would list current and potential members, donors, and so on.
USABILITY
73
From that list, you will want to think about the explicit objective that each kind of visitor might have and develop an action list with items like: Potential employers nding my resume Like-minded hobbyists contacting me School admission committees seeking a list of my recent projects Customers viewing how much our business charges for products and services New club members printing and mailing membership and payment forms Just like the everyone audience category, its tempting to say, Employers looking at every last page of my Web site. But that rarely, if ever, happens. Keep your list to specic and reasonable objectives.
74
index by linking to every single page from the navigation area. On small sites, linking to every page from the navigation may not be an issue. But on sites with more than a few pages, trying to cram everything into the navigation often results in y-out or pop-up menus that try (and often fail) to manage the information overload. Chapters 15 and 20 will present approaches to simplifying navigation and building a shallow architecture that make those kinds of workarounds unnecessary. Besides, because nding everything is such a rare user goal, it is better to concentrate your design efforts to address more common behaviors.
USABILITY
75
hyperlinked imagesuch as a sample from your design portfolio, if youre a designerelsewhere on your page might be more appealing, simply because the content of the image may t better with the vague idea of what a visitor to your site is looking for. A site with attractive previews and promotional content may even alter a users actions; visitors to a businesss Web site might discover a product or service that they didnt even realize that they wanted or needed previously.
76
USABILITY
77
The easiest way to build a site thats usable on the operational level is to let users be sloppy. Prefer large, clickable areas on links, navigation items, and images. (A test I often do is to see if I can mouse over page controls by moving my mouse with my elbow, which offers less control than my hand.) Provide high-contrast text run in a comfortably large font, with the ability to increase the font size further without breaking the pages layout, perhaps by employing DOM scripting (see Chapter 19). If users can be sloppythat is, if they arent constantly encountering breakdownsthey can better focus on their goals and actions.
78
along with the search terms to limit results to a specic site (e.g., vita site:karlstolley.com). Finding a few quality things. This test begins on your site itself. You might ask a user to nd items from your portfolio, or information about your club, its membership, and how to become a member. You can also conduct a more open-ended test, perhaps with a scenario like, If you were a potential customer, what would you look at to decide whether to buy from us? Finding a specic thing. Have your test users locate your resume, an About page, or a Contact page. Have your users nd something a little more specic, like a particular item in your portfolio. With this type of test, time might be important, so casually keep an eye on the clock of your computer or phone (do not use a stopwatch, though; its presence might unnecessarily stress your test users, as though taking a long time is their faultnot your sites). Finding a thing found before. If youre working with someone who tested your site previously, try repeating the test. Otherwise, have your test users nd a few different, specic things and thenassuming that rst test didnt go disastrouslyhave them rend the rst thing you asked them to.
Explain that your site is a work in progress (regardless of what stage its in; sites are always, to some extent, works in progress) and that you need help to improve it. If your test users are close friends or colleagues, they may not want to criticize the site for fear of hurting your feelings. But if you make it clear that you know there are issues to be improved, your test users will likely understand that they can help you more by sharing suggestions and criticisms than by telling you how awesome your site is (although thats nice to hear, too). Modify the tests above to match your specic site. If yours is a portfolio site, think about your expectations of why users would come to your site in the rst place, and what they would do there.
USABILITY
79
Ask the people you have try out your site to talk aloud. Listen to what they say, but also watch what theyre doing. Among usability professionals, its common knowledge that what users say and what they do are often quite different. But what they say aloudI expected a navigation button for that; Im surprised that image isnt clickable; This heading really grabbed my attention, but the writing below it doesnt seem to be what I wantcan be especially helpful for you to reconsider some of your design and writing decisions. Try doing quick revisions while the test users are with you, at least once you get more skilled writing and designing pages, and have them examine or try out your revised designs. You might even nd that some people will share design suggestions as you work. You shouldnt necessarily follow the suggestions exactly, but you might think about their subtext. For example, someone might say, I really think you should have a big photograph of yourself on your site. Unless youre a model, a theater major, or a newscaster, thats probably not essential, but what your test user might be implying is that your site needs to be more personal somehow, more uniquely you. A photograph may or may not be the way to achieve that particular goal. Regardless, asking test users one questionWhy?can usually help you determine why theyre offering the advice that they are. To do a certain kind of long-term, anonymous usability testing of all of your sites users, have a look at some of the sections on click tracking and other analytic tools in Chapter 24.
NEXT STEPS
Designing a usable site means accounting for different user activities, actions, and operations, all built on a solid foundation of accessibility. In the next chapter, we look at sustainability, which concerns accessibility, usability, and other writing and design issues over time and as your site grows.
80
NOTES
1. Steven Krug, Dont Make Me Think! A Common Sense Approach to Web Usability, 2nd ed. (Berkeley, CA: New Riders/Peachpit Press, 2006), 134. 2. Jakob Nielsen, Why You Only Need to Test with 5 Users (March 19, 2000), http://www.useit.com/alertbox/20000319.html 3. Jakob Nielsen, Usability 101: Introduction to Usability, http://www .useit.com/alertbox/20030825.html 4. Donald A. Norman, Emotional Design: Why We Love (Or Hate) Everyday Things (New York: Basic Books, 2004), 8. 5. Norman, Emotional Design, 1718. 6. Victor Kaptelinin and Bonnie A. Nardi, Acting with Technology: Activity Theory and Interaction Design (Cambridge, MA: The MIT Press, 2006). 7. StumbleUpon, http://www.stumbleupon.com/ 8. Peter Morville and Louis Rosenfeld, Information Architecture for the World Wide Web, 3rd ed. (Sebastopol, CA: OReilly Media, 2006), 3538. 9. Krug, Dont Make Me Think!, 135.
CHAP TE R
Sustainability
Accessibility requires designing for conditions. Usability requires designing for behaviors. Sustainability considers designing for conditions and behaviors in two dimensions: time and scale. Unlike accessibility and usability, which are inherently user-focused in that your own ability to access and use your site is only one small part of a broader picture, sustainability determines how well and how easily you are able to develop and rene your site over time. However, a sustainable site also ultimately benets users: the content, accessibility, and usability of a sustainable site are easier to revise and improve, ensuring the best content and experience for site users.
WHAT IS SUSTAINABILITY?
Sustainability is often referred to in the context of the natural environment. One of the more widely quoted denitions of sustainability comes from the 1987 meeting of the World Commission on Environment and Development, also known as the Brutland Commission. Their denition of sustainability reads: Development that meets the needs of the present without compromising the ability of future generations to meet their own needs.1 It is not a major effort to rework this statement with regard to Web design: sustainable Web design meets present needs of a sites creator and users, without compromising their future needs. Going a step further, one might say that sustainable Web design meets present needs while also planning for future needs.
82
Unfortunately, people who write and design for the Web (and other digital media) have tended to ignore sustainability at every turn, opting to follow fads and trends or the easy path of using a WYSIWYG editor to build pages. It is not enough for a page or site to be built (a present need); it should also conform to Web standards and be easy to revise and improve the page over time and as a site grows (future needs).
SUSTAINABILITY
83
84
In addition to keeping a log of your sites changes, its very important to write comments in your XHTML, CSS, and JavaScript source. Not only does this help preserve your own sanity, but it can help to teach others who are impressed by your site and want to learn how to do something the way that you have. Chapter 12 describes some basic commenting practices, and the Web-available examples that support this book at http://sustainablewebdesign.com/book/ are also lled with comments, in case you are looking for additional examples of commenting.
Call It Like It Is
Whether you are choosing a domain name, naming les and folders, or writing classes and IDs in your XHTML, the best thing that you can do is to name things to reect what they are, and maintain a consistent naming style across all of your sites elements, including XHTML and CSS les, plus images and other media.
SUSTAINABILITY
85
As the le-naming advice offered in Chapter 5 suggests, its never good practice to use words like new in le names, as nothing remains new over time. But its also not good practice to truncate or abbreviate le and folder names; little is gained by calling your resume page res. htm; call it resume.htm. Both for you as the creator of a site and your visitors, le names in URLs provide additional clues to whether something should be clicked on, or where something is with respect to the rest of your site. If the URL reads http://example.com/contact.htm, it is reasonable to expect that the page will have information or the means (such as a form) for contacting the sites owner or organization. So be sure, too, that the content of a page matches what its le name suggests. In terms of scale, any numbered, or serialized, le names should begin with leading zeros, such as photo001.jpg, photo002.jpg, photo003. jpg. This helps keep the listings of serialized les more readable when you are managing your sites les. Otherwise, photo10.jpg will be listed next to photo1.jpg, photo20.jpg near photo2.jpg, and so on. When it comes to the structure of your XHTML pages, the call it like it is rule also applies. Even on a basic tag level, tag headings with heading tags, lists with list tags, and so on. Take extra care in naming classes and IDs, too. What in your current design is a big purple box may not be in a redesign. So rather than naming a class or ID something like big-purple-box, name it promotional-content or some other name that describes the contents structure and purpose, not its design (see Chapter 9).
86
For example, if you choose to post a vague folder or le name, like stuff/ or res.htm and later opt to rename it to something more meaningful, you risk making links to the older name obsolete, so be sure to both name things and place things in a thoughtful, sensible place the rst time around. There are some advanced techniques, such as using the Apache Web servers URL rewrite module,2 to redirect old URLs to new and active ones. While those techniques are outside of the scope of this book, they do add a degree of exibility for handling links to old URLs should you need to construct a new architecture for your site. See this books companion site for additional information, http://sustainableweb design.com/book/.
SUSTAINABILITY
87
publishing an entirely new design is accomplished by replacing your old CSS le with a new, redesigned one. Like your design, any content that you repeat over pagesyour heading, navigation, even brief About Me textcan also be kept in a single le, and then repeated over multiple pages using a server-side language like PHP (see Chapter 21). But even the page-specic content you mark up in XHTML should also appear only in one place; using CSS and the media attribute, you can style one XHTML page to display differently on different devices or when the page is printed. Theres no need, in other words, to have one XHTML le for print, one XHTML le for screen, and so on. As soon as you introduce multiple copies of the same content, you increase the labor involved in even the smallest changes. If you nd a typo, you have to x it in as many different les as you maintain copies.
88
NEXT STEPS
Sustainable Web design isnt magic. It just requires thinking carefully about a lot of choices, such as naming things, that are easily overlooked and taken for granted. In the next section of the book, Strategies for Success, we will see the issues of accessibility, usability, and sustainability in action as you get down to the work of building your site.
NOTES
1. Report of the World Commission on Environment and Development, Towards Sustainable Development, Our Common Future (1987), http:// www.un-documents.net/ocf-02.htm 2. Apache HTTP Server Version 2.2, Apache Module mod_rewrite (2009), http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
PAR T
I I I
CHAP TE R
92
and design. This allows your structured content to be interpreted and reused by Web browsers and other devices and, using multiple mediaspecic style sheets, presented in different ways for different devices and people. Structured content can, for example, refer to different CSS les so as to display on screen one way, and in print another. Screen readers and other adaptive technologies can use XHTML to provide a meaningful experience for low-vision users, without the interference that visual design might bring if design were blended in with the XHTML. XHTML is challenging to write only because we are used to thinking about the structure of writing in visual ways. When you ip through a magazine, you recognize headings, paragraphs, bulleted lists, and other common structural features because of their visual design. Headings are often large, bold, and distinguishable from running paragraph text. Lists feature bullets, numbers, or even images next to short chunks of text, which might be indented differently from paragraphs. That is a common way of thinking when we write, too. A word processor allows writers to highlight a piece of text and change its appearance: making it bold, changing its font and size, and adding color. The idea that a combination of design choices adds structure to the document may never enter a writers mind. But on the Web, structure is essential to making a Web page maximally accessible, even to nonvisual devices such as search engine spiders and screen readers. For that reason, structure on the Web is not indicated visually in XHTML. Yet as we will see, structured XHTML is essential to creating CSS-based design and adding page enhancements with JavaScript. XHTML, like the XML rules it is based on (see Chapter 4), provides writers with tags to describe the structure of their writing. Headings are marked with heading tags (<h1> through <h6>); paragraphs are marked with paragraph tags (<p>); items in a list are marked with list item tags (<li>) and list items are grouped as either unordered (bulleted) lists (<ul>) or ordered (numbered) lists (<ol>).
STRUCTURED CONTENT
93
Quotation marks do not make text especially beautiful; they function only to indicate structure. A quotation mark sets off text to indicate structural differences in writing: the speech or writing of another person, the title of a magazine article, or perhaps an unfamiliar word or phrase. Quotation marks also appear in predictable ways, adjacent to the material they mark and without any spaces:
I said, "XHTML tags are a lot like quotation marks."
Not
I said, " XHTML tags are a lot like quotation marks. "
Once a quotation mark opens, it also must close, or the text becomes confusing:
"The Road Not Taken by Robert Frost is one of America's most beloved poems.
And if single quotation marks appear within double quotation marks, there is another important rule: the single quotation marks must close before the doubles:
"Tonight I will read you a poem by Robert Frost, 'The Road Not Taken.'"
Quotation marks also look the same regardless of the content they mark:
"The Road Not Taken" "Ask not what your country can do for you; ask what you can do for your country."
Despite quotation marks looking the same, literate humans usually can distinguish whether the quotation marks are structuring a title (The Road Not Taken) or a line from a famous speech (Ask not . . .). We rely on context and prior knowledge to make such distinctions. Computers and Web browsers are not nearly as smart as humans. They must be told exactly what something is: the purpose of XHTML tags is to describe the structure of writing. XHTML tags obey the same rules as quotation marks. XHTML, at least on its surface, can be seen as a set of fancy quotation marks that
94
lets writers explicitly describe the structure of writing. If I write an article as a Web page and its title is Simple Rules for Using XHTML, I might structure the title as a rst-level heading (<h1>):
<h1>Simple Rules for Using XHTML</h1>
Structurally, this text is a rst-level heading regardless of whether the CSS designs it to appear big and purple or little and green, in Times New Roman or Arial, or whether it even appears visibly on the page at all. Regardless of how the heading is visually designed, in other words, its structural meaning will always be the same.
Its not necessary to understand what all of that means; just be sure it appears as the rst line of all of your XHTML documents. (The XHTML les in the Rapid Prototyping Kit, RPK, all use the XHTML 1.0 Strict DOCTYPE.) 2. Every tag that opens must close. If <p> opens, a closing tag, </p> must follow. (Just like quotation marks.) Some tags, such as the line break (<br />) and image (<img />) tags, do not surround text and are therefore self-closing: rather than having an opening and closing tag, they self-close with a space and a (forward) slash: />.
STRUCTURED CONTENT
95
3. Tags close in the opposite order that they open, just like single quotation marks inside of doubles:
<p>To structure text that will be bold, use the <strong>strong tag</strong>.</p>
(<p> opens, then <strong>; </strong> closes, then </p>.) 4. All tag elements and attributes, and some attribute-values, must be lowercase letters. Heres an illustrative, nonsense bit of XHTML that illustrates the element, attribute, and value parts of the tag:
<element attribute="value">
So in this example,
<address class="ofce">
the element, or tag name, is address; it has one attribute, class, and that attributes value is ofce. ofce can also be called an attributevalue. Not all attribute-values must be lowercase. For example, all <img /> (image) tags require an alt attribute for alternative text that users will see or hear on devices that cannot display images. The attribute value for the alt attribute should actually be a descriptive phrase or a sentence:
<img src="apple-pie.jpg" alt="Photograph of the apple pie I baked." />
As that example also shows, tags sometimes have multiple attributes (in that case, src and alt), which are separated by a space. 5. All attribute-values must appear in quotation marks, immediately following the equals sign. There should also never be a space between the equals sign and the opening quotation mark; spaces are used to separate elements from attributes, and attributes from other attributes:
<h1 class="running-head">
6. All class and id values must begin with a letter, and must not contain spaces. Never begin a class or id value with a number or punctuation. Except for special values, such as microformats,3 you
96
must invent class and id values yourself, in ways that describe the content (not the visual design) of your pages:
<ul id="navigation" class="active">
Classes and IDs also should only contain lowercase letters and the hyphen. Other characters are allowed, including capital letters. But keeping everything lowercase will do good things for your sanity, particularly when you are writing CSS to design your XHTML: by consistently using only lowercase letters, youll be certain that youve named your class navigation, not Navigation. Also, some attributes allow writers to specify multiple values, each of which is separated by a space. For example, a paragraph tag could have the classes of rst and summary:
<p class="rst summary">
For that reason, you cannot use spaces when creating class names (or IDs). Keeping those six rules in mind (refer back to them if you need a refresher later), lets examine the global structure of all standard XHTML pages.
Each of those tags can appear only once per page. Lets walk through these so that you can begin to build a mental model of the structural blocks required for all XHTML pages.
STRUCTURED CONTENT
97
that should appear in the <html> tag, its primary structural function is to serve as the tag that groups both the <head> and <body> tags. Because of this, the <html> tag is sometimes referred to as the root element of all Web pages. It is the tag that contains all others. But page content does not appear immediately inside the <html> tag. Instead, <html> is divided into two parts: <head> and <body>.
The rst attribute-value pair of http-equiv describes the pages content type to search engines and browsers. This helps browsers to accurately render the type of content that your XHTML page contains. In this case, the content attribute tells search engines and Web browsers that the page content that follows is of a particular type, text/html, and that it uses the character set utf-8. We will look at these and other <meta> tags in subsequent chapters on metadata (Chapter 13) and sharing (Chapter 24).
98
Web pages to help you better organize and design your page content inside of <body>.
STRUCTURED CONTENT Creative Commons Attribution 3.0 United States License</a>. </p> </body>
99
In that basic, structural form, there is nothing indicating the different content areas of the page, such as a page header, a main content area, a site navigation (the unordered list), or a footer (the Creative Commons license). With the addition of some <div> tags, whose purpose is to group page content into divisions, and structurally named id attributes to distinguish the different sections, the pages source might look like:
<body> <div id="header"> <h1>John Smith's Home Page</h1> </div> <div id="content"> <h2>Portfolio Overview</h2> <p>Read all about <a href="portfolio.htm">my portfolio</a>...</p> <h2>Latest Projects</h2> <p>Read all about my <a href="latestprojects.htm">latest projects</a> ...</p> </div> <ul id="navigation"> <li><a href="index.htm">Home</a></li> <li><a href="resume.htm">Resume</a></li> <li><a href="contact.htm">Contact</a></li> </ul> <div id="footer"> <p>All site content is licensed for use under a <a rel="license" href="http://creativecommons.org/licenses/by /3.0/us/">Creative Commons Attribution 3.0 United States License</a>.</p> </div> </body>
100
Note that in some cases, <div> tags have to be added to structurally group areas of your page; however, because the <ul> tag on the site navigation already groups the list item tags, I put the id attribute directly on the <ul> tag. The lesson here, which will be made clearer in Chapter 16s treatment of XHTML tags for page content, is never to use or add a <div> tag if there is a more suitable structural tag available. The less XHTML you write, the easier your pages will be to maintain. Also note that you can use add the hash (#) followed by a unique ID in your URL to point a visitor to a particular part of your page. For example, to point someones browser to the site navigation in the example above, we could write a URL like http://example .com/#navigation. Most browsers will scroll to the hash-referenced area of the page automatically.
Like unique IDs, you can add classes to any tag requiring more specic structure. Note that the class and ID names do not appear in a browser view of your Web page, but as we will see in the coming chapters, they
STRUCTURED CONTENT
101
can be very useful when applying additional CSS styles and advanced DOM Scripting.
In that case, rather than adding the class to every single list item, it would be better to add it on the <ul> tag that groups all of the list items:
<ul class="favorite-foods"> <li>Pizza</li>
102
</ul>
That will keep the pages markup lighter, easier to read, and easier to revise. Ill say it again: the less XHTML you write, while still being descriptive of your content, the better.
NEXT STEPS
This chapter has covered the basic rules of XHTML, and the major structural features of every XHTML page. The next chapter will introduce CSS, which you can begin to write while you develop your skills with XHTML. See also the chapters in the Issues and Challenges section to review XHTMLs importance to the accessibility, usability, and sustainability of Web sites.
NOTES
1. HTML Dog, HTML Tags, http://htmldog.com/reference/htmltags/ 2. SitePoint, HTML Reference, http://reference.sitepoint.com/html 3. Microformats.org, http://microformats.org
CHAP TE R
10
Cascading Style Sheets (CSS) enable the visual presentation and design of Web pages. From typography to color, page layout to textural and other design images, CSS controls the look of content structured in XHTML. While you can look at an XHTML le directly in a Web browser, which will provide default styling (Figure 10.1), CSS cannot be viewed directly (all youll see is the CSS source itself); a browser has to layer CSS over an XHTML le. That means you must have your structural XHTML in place before you can test your design work in CSS. A primary capability of CSS is inheritance, which refers to the abilities of certain style properties to transfer from parent elements (e.g., the <body> tag) to their children (e.g., <p> inside of <body>; familial relationships are covered later in this chapter). A good CSS reference will let you know whether a given property is inherited or not, although the majority of inherited properties are text- and font-related. If, for example, you want all of your text on a page to be in Arial font, you do not need to specify Arial for each and every tag; because the CSS font-family property is inherited, you can just specify it on the <body> tag, which is the parent (or ancestor) element of all content on an XHTML page. The cascade in CSS refers to the ability of styles to come from multiple sources (les, selectors, plus the default browser stylingwhich should be removed using a reset CSS le; see Chapter 11), with the more specic style being applied. Figure 10.2 shows the default browser styling, with the exception
Figure 10.2. The same sample as Figure 10.1, but with Arial font on the body selector in CSS.
105
of this style declaration for the <body> tagwhich is inherited by all text on the page:
body { font-family: Arial, sans-serif; }
106
BASIC SELECTORS
Selectors in CSS describe the XHTML structure that will be styled. Using the house metaphor from the XHTML chapter, CSS selectors are like instructions to interior decorators for what they should decorate: the replace, the upstairs bathroom, the closets in the master bedroom. Except instead of referring to rooms in a house, CSS selectors refer to tags and tag relationships in your XHTML source.
Element Selectors
The most basic CSS selectors are XHTML tag elements (sometimes called type selectors). The only thing to remember is that while XHTML puts the element in angle brackets, like <body> or <p>, in CSS the element appears by itself: body or p. Any XHTML tag can be a selector in CSS, and the selector will style that particular tag the way you specify, wherever it appears on your page. For example, to set all paragraph text to appear in blue, youd write in CSS:
p { color: blue; }
or
div#footer { background: gray; }
Either method works; I prefer to put the element with the ID, just to help myself remember more about what Im styling. If you had a class called warning (e.g., <p class="warning">), perhaps on a site with instructions for doing something that might be potentially dangerous (such as operating a power saw), you could style that class as either
.warning { color: red; }
107
or
p.warning { color: red; }
Adding the tag element to the class selector can give you ner-grained control over the look of your page, particularly if you use the same class on different XHTML tags, but want to style the class differently, depending on the tag the class appears on.
RELATIONSHIP SELECTORS
CSS selectors can also be formed based on the relationships between elements in XHTML pages. CSS (like the DOM, see Chapter 19) relies on relationships in terms you already know from your family tree: parents, children, siblings; as well as ancestors and descendants.
Descendant Selectors
Descendant selectors are formed by a list of at least two elements or classes/IDs, each separated by a space. The selector styles the last element listed. For example, to style all of the anchor tags (links) in the navigation so that they are not underlined (Figure 10.3), you could write a descendant selector:
ul#navigation a { text-decoration: none; }
All anchor tags (<a>) inside of <ul id="navigation"> will appear without the default underlining of hyperlinks. Other links on the page will still have an underline. To remove underlining from all links, you could just refer to the a element selector:
a { text-decoration: none; }
Child Selectors
Child selectors are a more specic form of descendant selector intended to style an element only if it is a child, or direct descendant, of the parent element. The child selector is most useful for noninherited CSS properties, such as list-style-type. Child selectors are written by putting an angle bracket between two elements. The following selector will style all child <li> tags of <ul id="navigation">,
108
Figure 10.3. In this example, only the anchor tags that are descendants of the navigation list have their default underlining removed.
but not the <li> tags of any more deeply nested lists (which would be descendants, but not children; see Chapter 16):
ul.colors > li { list-style-type: none; }
You can see in Figure 10.4 that the immediate children of <ul class="colors"> have no bullet points, but the grandchildren still do.
Sibling Selectors
Sibling selectors target adjacent XHTML elements that share a parent. For example, if someone wanted a paragraph appearing immediately following a heading two (<h2>) tag to run in bold, the sibling selector, +, accomplishes this:
h2 + p { font-weight: bold; }
One limitation of the sibling selectors is that you can only target the sibling appearing after the rst. That is, if this were the XHTML:
<div id="content"> <h2>My Header Two Tag</h2> <p>My paragraph text.</p> </div>
109
The rst selector styles all link text blue; the second styles links with an external class as red, while the third styles links in the navigation green. But given that all three styles ultimately refer to <a> in the XHTML, how does a Web browser know to style the external links red and all other links bluegiven that the selector in the rst style is supposed to style all of the links on the page? Selectors have different levels of specicity in CSS. Andy Clarke has a fascinating blog post that uses Star Wars characters to illustrate selector specicity visually.* Along with that, Clarkes post refers to a point system for calculating specicity; essentially, elements in a selector get one point, classes in selectors get 10 points, and IDs in a selector get 100 points. When multiple selectors match the same element, the selector with the most points determines how the element is styled. So in the examples above, the rst selector gets one point, the second gets 11 points (element plus class), and the third gets 102 points (an element plus an ID plus another element). The more specic stylethat is, the style with the most points in this systemis the one that gets applied to the matching XHTML structure. Thats why the navigation items in the list of styles above will appear green, not blueeven if there were an <a class="external"> match within <ul id="navigation">; to style that would require a selector like
ul#navigation a.external { /*Styles here*/ }
whose point value would be 112 (two elements, one class, and one ID) and therefore more specic.
*Andy Clarke, CSS: Specity Wars, Stuff and Nonsense, http://www.stuffandnonsense.co.uk/ archives/css_specicity_wars.html
the sibling selector would allow us to style the paragraph element, but not the heading-two element. That is, we can say in CSS style paragraphs appearing immediately after heading-two but not style heading-twos appearing before a paragraph. Thats just a limitation of
110
Figure 10.4. Using the child selector, only the rst children of this list appear without bullets; more deeply nested lists still have their bullets.
CSS; but there are always other solutions. To style that heading two, it might just be better to add a class to it in your XHTML when it appears before paragraphs (if there is something structurally special about the heading two in that situation).
Universal Selector
One nal selector worth mentioning is the universal selector, *, sometimes called the wildcard selector. Used by itself, it will style all elements on the page; for example,
* { color: green; }
will style all text on the page to make it appear green. (However, because color is inherited, it is generally better to set it using the body element selector.) For both class and ID selectors, the wildcard selector is implied. That is, there is no difference between
.warning { color: red; }
and
*.warning { color: red; }
111
The wildcard selector is at its most useful in relationship selectors. For example, if a page contained the following XHTML:
<p> This is <strong>an example</strong> of <a href="example.htm">styling the text in <strong>this strong tag</strong></a> <em>as well as <strong>this strong tag</strong></em>. </p>
only the rst <strong> tag (marking an example) is a child of <p>. The other two are children of other tags (<a> and <em>). To style the strong tags that arent children of <p>, use the wildcard selector:
p * strong { /*Style information*/ }
That would style all strong tags that are grandchildren of paragraphs: meaning, there must be one or more descendant elements between p and strong for this style to be applied. We could also use the child selector, rather than the descendant selector, for more specic parentchild relationships (e.g., that only one element appears between p and strong):
p > * > strong { /*Style information*/ }
However, in those two cases, both selectors would apply the same styles to the XHTML above.
Combining Selectors
You can write selectors as descriptively and specically as you like, so long as they match actual familial relationships and structural components in your XHTML. A match is what triggers a Web browser to apply the style. For example, to style a paragraph that is an adjacent sibling of a heading-two tag that is a child of <div id="content">, provided that div#content is not a child of the body tag, the CSS selector would look like:
body * div#content > h2 + p { /*Style information*/ }
However, youll probably be relieved to know that its rare to have to write such complicated selectors. Rare, but possible. (See the Selectors
112
and Specicity sidebar above, which will be useful knowledge if you have to write complex selectors.)
Grouping Selectors
There are times when you might want multiple structural features in your XHTML to be styled the same way; for example, both the <b> (bold) and <strong> tag might be styled as bold by your CSS. The long way to do that would be to write two separate style declarations:
b { font-weight: bold; } strong { font-weight: bold; }
But by using the comma, both selectors can be styled together. The comma enables designers to style many additional elements to appear in bold, such as all of the headings:
b, strong, h1, h2, h3, h4, h5, h6 { font-weight: bold; }
Then, any distinct styles for a given selector could be handled by additional selectors in the same style sheet; for example, h1 has already been styled bold, but to make it purple (as well as bold) requires only another style declaration that contains only the color property:
h1 { color: purple; } /*Already made bold above.*/
Pseudo-Class Selectors
CSS provides ve special pseudo-class selectors, which are most often used for styling link text appearing inside the <a> tag: :link styles a link in its unvisited state :visited styles a link that has been visited :hover styles a link that is being moused over, and should usually be combined with :focus, which styles a link that has been, for example, tabbed to by a keyboard :active styles a link during the brief moment that it has been activated by a mouse click or pressing the Return key on the keyboard
113
So to make links green and no underline, hovered/active links underlined and green, and visited links red, a style sheet might have a cluster of styles like:
a,a:link { color: green; text-decoration: none; } a:visited { color: red; } a:hover,a:active { text-decoration: underline; } :hover and :focus also work on XHTML elements in forms for entering user information.
the Web browser will display Times New Roman (which is placed in quotation marks because of the spaces in the fonts name, but place the comma outside the quotation marks); if the computer the browser is running on does not have Times New Roman but does have Times, it will use Times; if it doesnt have Times either, it will display whatever serif font is available on the system. For accessibility purposes, always be sure to specify a generic font alternative at the end of all lists of fonts: serif,
114
HOW TO DESIGN AND WRITE WEB PAGES TODAY sans-serif, or monospace. You can nd a current list of
commonly available fonts at this books companion Web site, http://sustainablewebdesign.com/book/. font-size: Font sizes can be set in a number of different units; points (pt) are used for print style sheets. Screen style sheets can use keywords, such as small, medium, and large; pixels (px); percentages (%); or ems (em). font-weight: Font weight can be specied as a number in multiples of 100, but is more often specied as bold, which makes the font appear bold, or normal, which makes the font appear normal (not bold). Normal is often used to reset a bold style inherited from another selector; if the strong tag, by itself, is set to bold, strong { font-weight: bold; }, but you dont want bold on strong inside of an anchor tag, youd write:
a strong { font-weight: normal; }
font-style: Font style is usually either set to italic, for italics, or normal for nonitalic text. color: The color property species text color. You can write color keywords like those found in small boxes of crayons (e.g., red, blue, or green). To gain better control over color, write the hexadecimal number for a color (e.g., #FFFFFF for white) or the RGB value using rgb(255,255,255), which would also produce white. line-height: Line height can be expressed as numbers without a unit; for example, line-height: 1.5; makes text one-and-a-half-spaced, line-height: 2; makes text double-spaced. You can also use pixel units, although that may cause problems if a user tries to resize the text on your site. text-indent: To indent the rst line of text, use the textindent property and a value in pixels or ems. To mimic a hanging indent (see Figure 10.5), run a negative number for text-indent and then the same but positive value for padding-left. For example,
ul.citation li { text-indent: -50px; padding-left: 50px; }
115
Figure 10.5. Example of a hanging indent on a paragraph at the bottom of the screen; ordinarily, references or works cited should be in list items in ordered or unordered lists.
116
the content, or it can take four values in trouble order: Top Right Bottom Left (TRBL). margin: Margin increases the distance between the element and other elements on your page, or from the edge of the browser viewport. Without a background color or background image, margin and padding appear to do the same thing (increased space), but margins are transparent. height: It is possible to set the height on an element. This is usually done in image replacement situations (see Chapters 14 and 17). The problem with height is that some browsers will maintain the height you specify, even if the content is longer/ taller, whereas other browsers will expand the height to t the content. width: By contrast, width is specied quite often, especially to help build page layouts. It is usually best practice to set widths on a containing division or ordered or unordered list, rather
117
than individual elements. As with height, elements that have their width specied will add any padding to the total width. So for example,
ul#navigation { width: 200px; padding: 20px; }
will result in the navigation appearing 240 pixels wide (200 width + 20 left padding + 20 right padding = 240).
118
display: Display is a versatile property for setting how and whether an item displays. display: none; causes the item to disappear from view (potentially also to assistive technologies, which may be an accessibility issue). display: block; causes an item to appear as a block element, while display: inline; will make an item appear like an inline element, such as <strong> or <em> usually appear.
119
reference nearby, especially for shorthand properties like background and border.
NEXT STEPS
Now that youve had an introduction to CSS and have a list of some (but certainly not all) of CSSs properties, it will be easier to see how both XHTML and CSS can be used to build different parts of your pages: the branding, navigation, content, and so on. To get started, we will get to work with the Rapid Prototyping Kit (RPK) and, in Chapter 12, explore writing with source in a text editor.
NOTES
1. HTML Dog, "CSS Properties," http://htmldog.com/reference/ cssproperties/ 2. SitePoint, SitePoint CSS Reference, http://reference.sitepoint .com/css
CHAP TE R
11
Rapid Prototyping
One of the better ways to stay motivated to complete your Web site is to make visible progress on it quickly. The Rapid Prototyping Kit (RPK), available as a free download at http://sustainablewebdesign .com/book/, will aid you in building a site with solid, standardscompliant pages. This chapter looks at the benets of rapid prototyping and the basic steps of building a Web page using the RPK: gathering content, sketching out a rough layout, structuring content in XHTML, and adding design features in CSS. Those steps will be explored further in subsequent chapters. But consider this chapter part road map, part crash course.
122
can devote yourself to the sites ongoing improvement and expansion over time. As Chapter 3 urged, have some content on hand and ideas in mind as you begin to rapidly prototype your Web site. The best preparation for building a Web site is to gather and create as much of the sites content as possible (knowing, of course, that content will change over time and based on your design). It is actual content that drives the design of your site.
RAPID PROTOTYPING
123
A development environment, which should be comfortable for you to use but experimented with as part of learning (see Chapter 5). A long-term attitude toward writing and designing for the Web, which expects only steady progress and learning (and lots of mistakes), not perfection or instant mastery.
124
Figure 11.1.
You can browse the RPKs les on the Web; this is a view of the
version of the RPK used in this book will always be available. Below is a rough outline of the RPK as of the writing of this book.)
RAPID PROTOTYPING
125
(Chapter 20 provides guidance for adding your own folders to structure and organize your site architecture.) The RPKs folder structure can be changed as needed; but if you are new to Web design, it provides workable solutions to keep the contents of your site organized.
126
Figure 11.2. A part of prototype.htm visible in the Notepad++ editor, revealing the les source order.
however, it is possible to place the navigation wherever you would like it to appear on the pagewhile keeping the source order friendly to search engines and low-vision, text-only users (who can jump down the page to the navigation using special accessibility links discussed in Chapter 14).
Figure 11.3. This is what prototype.htm looks like without any styles of its own, and therefore styled by the Firefoxs default CSS styles.
Figure 11.4. The same page as Figure 11.3, but with the Reset CSS in place.
128
and padding around elements, removes all of the font sizes on the different headings, and even removes bold and italic styling from tags that would otherwise be bold and italic in most browsers. To account for that, the RPK also includes CSS at the top of screen.css that adds back some of the common styles that the Reset CSS removes (see Figure 11.5). Specically, it puts bold back on the headings and the bold and strong tags; italics back on the italic, emphasis, and cite tags; and puts a dotted border back on the acronym and abbreviation tags. If you do not wish to use the base styles, remove or adjust them. The basic lesson from the Reset CSS is that you have to specify everything about your designeven things like bold on tags where you would expect bold. Everything else is completely unstyled: there is no space around any of the headings, paragraphs, or lists, which also lack even bullets. The idea behind this is that you are now free to style your page exactly as you want it to appear. If you need bullets next to your unordered lists, for example, you have to specify them in your CSS. Its potentially
Figure 11.5. The same page as Figures 11.3 and 11.4, but with some base CSS styles added back in after applying the Reset CSS. This is how prototype. htm will look when you rst open your own copy.
RAPID PROTOTYPING
129
extra work to add bullets, yes, but only if you want those and other design features to appear. If, for example, you want no bullets next to your navigation list, no problem. Theyre not there anyway. But if you do want bullets, you can be more condent that they will appear as you intend across standards-compliant Web browsers. For adding those and other custom styles, there is a screen.css le that is empty except for the base styles mentioned above and some useful selectors (see Chapter 10) for styling particular content areas and structural features found in prototype.htm.
130
create pages based on your own starter page that has most of your shared page features in place. (See Chapter 21 for building a more dynamic, reusable set of shared content features.) Develop a representative page from your site. The urge that most designers have is to start with the home page, but it is often very different from the content pages of a site. I recommend starting with an About Metype page; not only will that likely be representative of your sites other pages, but its contents will also help you to gure out what other pages to include in your site. Mark up your text and image content in XHTML. Once you have a rough draft of your content, start tagging it with XHTML, particularly its headings, paragraphs, and lists (see Chapter 16). Begin to develop site typography. Choosing fonts and font sizes, as well as line heights, will help you to get your page into a shape that makes it readable and lead you to creating a site style guide for text (see Chapter 16). A current list of fonts that are safe to use on the Web is available at http://sus tainablewebdesign.com/book/; just because a font is on your computer does not mean it will be available on others. Be prepared to adjust your typography later on to maximize readability according to your page layout. Sketch out a rough layout for your site. This is mostly about geography, not the sites actual look: Where will the header and footer appear? The navigation? Your content and subcontent areas? Your rough sketch will guide your work in Chapter 17 on page layout. Use CSS to position your page elements. As Chapter 17 demonstrates, CSS layouts are basically illusions, sort of like the little slider puzzles you may have had as a child, where there were nine spots for eight pieces of an image to go, and you had to slide things around in order to get the picture to look the way its supposed to. Use an image editor to build in textures and background images, and nalize dimensions, particularly widths, for the different elements on your page. This is where you work to really
RAPID PROTOTYPING
131
build the look and feel of your pages. Once you know you are able to get your page elements to roughly where you want them, you can use your image editor to create a striking design.
But when you see that kind of markup, where two or more tags mark the same content, its time to rethink your strategy. One alternative to that use of the <strong> tag is to add a class to the paragraph, like <p class="important"> and then in the CSS specify p.important { font-weight: bold; }. Dont forget to remove the unnecessary <strong> tags from your markup, though.
132
Think about the general, then move to the specic. The advice above suggests to begin site design by working with a representative content page from your site; this helps you think about what most pages will include structurally and how they will be designed. From that, you can design pages that are slightly different, such as the home page. Chapter 13 suggests using a class on the body tag to give you a hook to style different types of pages, while maintaining lean source and a single CSS le. Devote a little time every week or so to improve something on your site. Like any other skills, your Web writing and design skills depend on your exercising them every so often. Coming back to your site regularly, as your schedule allows, will keep your current skills freshand help you to learn new ones (see the Resources for the Future section for material that will advance your abilities beyond this book and keep you current on the latest and best approaches to Web design).
NEXT STEPS
To build and edit your pages with the RPK requires only a simple text editor, which the next chapter discusses. If youre comfortable working with a text editor, you may want to skip ahead to Chapter 13.
NOTES
1. Eric S. Raymond, The Cathedral and the Bazaar: Musings on Linux and Open Source by an Accidental Revolutionary, revised and expanded ed. (Sebastopol, CA: OReilly Media, 2001), 25. 2. 7-Zip, Download, http://www.7-zip.org/download.html 3. Yahoo! Developer Network, YUI 2: Reset CSS, http://developer .yahoo.com/yui/reset/ 4. jQuery.com, jQuery: The Write Less, Do More JavaScript Library, http:// jquery.com/
CHAP TE R
12
If youre used to writing in a word processor or a WYSIWYG Web editor, one of the rst things that may strike you about writing in a simple text editor like TextWrangler or Notepad++ is the relative lack of buttons and other screen clutter (see Figure 12.1). At rst, this lack of buttons can be disorienting, even alarming: word processors and even email programs have conditioned us to write with a lot of machine assistance, particularly for formatting. But the text editors simplicity is actually a good thing. In a text editor, what matters most is what you write yourself. And thats what you do in an editor: you write. The important thing about a text editor, like the Web pages that you create with it, is that there are no hidden mysteries. The WYSIWYG acronyms popular usage aside, in an editor, what you see really is what you getat least in terms of the sets of instructions that browsers turn into Web pages. If youve ever used a word processor, you know that sometimes, weird things happen. For no apparent reason. A paragraph gets a bullet point next to it, and nothing you do to appease and reassure the software seems to remove the bullet point. A paragraph changes font right in the middle, but again with no apparent or apparently xable reason. Most people confronted with such a situation will just start a new document from scratchor live with the weirdness. In the text editor, nothing you write and nothing about your Web pages is hidden from view. And that means that, with even a little bit
134
of source literacy, you have maximum control over your pages. More important, when something is wrong with one of your pages, you can be certain that its something you can x.
135
Figure 12.2. The le components of a simple page, as displayed by the operating system: in this case, an XHTML le, a CSS le, and a PNG image le.
les, JavaScript in .js les, and so on (be sure that you have congured your operating system to show all le extensions; see Chapter 5). The le view also guides you in how to write URLs so that when you write a reference from one le, like an XHTML page, to another le, like an image, the link between the two actually works (see the discussion of links and paths in Chapter 20). Source View: When you use your editor to open up an XHTML or CSS le, you are looking at the les source view (see Figure 12.3). You can also access the source view of any page on the Web by choosing something like View > Source from within a Web browser. Looking at the source of other pages on the Web is a great way to learn how other people build pages. Browser View: This is how we usually experience Web pages; the browser view is how pages display or render in a browser itself (see Figure 12.4). However, each browser or mobile or adaptive device provides a different, unique view of a given Web page, as discussed in Chapter 2.
Figure 12.3. The source view of an XHTML le, which links to the CSS le on Line 6 and the image le on Line 17.
Figure 12.4. The browser pulls all the les together, thanks to the instructions in the XHTML le, which references the CSS and image les. The image le is actually a screen shot of the le view in the Ubuntu Linux operating system.
137
Each viewle, source, and browserwill be slightly different, depending on details such as your operating system (Mac OS, Windows, Linux), your editor (TextWrangler, Notepad++), and your browser (Firefox, Chrome, Safari). Available fonts, screen resolutions, and even display types (LCD panels or older CRT displays) all affect views. But regardless of those details, what each view represents in terms of your sites les, source, page rendering is the same.
SYNTAX HIGHLIGHTING
Good text editors can provide more than views of source in simple black and white text, though. Colorized text, better known as syntax highlighting, makes writing XHTML, CSS, JavaScript, and your content more comfortable and efcient. Despite their general lack of features, one feature that any good text editor will have is syntax highlighting. Syntax highlighting provides a set of visual cues about the contents of your les. Good editors will
Figure 12.5. A missing angle bracket on line 16 causes Notepad++s syntax highlighting to colorize all of the following text as though it were a tag. To x these kinds of errors, watch for the line at which they start, then study your source more closely.
138
display XHTML les, for example, with tags colored differently from the text content that the tags structure. Attributes and attribute-values may be colored differently from the tag element, and so on. The colors for syntax highlighting vary from editor to editor (e.g., coloring tags blue, green, or purple); the individual colors do not matter. What does matter is the differences in color from one feature of your source (e.g., tags, attributes) and another (e.g., text content). For example, if you forget to put a closing angle bracket on a tag, or a closing quotation mark on an attribute-value, the colors for tags or attributevalues will colorize everything that follows as a tag or attribute-value (see Figure 12.5). This is an important way to track down the simplest and most common errors that most of us create when we write Web pages. If the syntax highlighting of a page suddenly stops changing over a large stretchor otherwise looks different from other, similar areas of the pagelook for the spot at which the change begins. Its more than likely that you will nd the source of the problem nearby.
SOURCE FORMATTING
Unlike word processors, which format text to a particular printed page size, text editors have no associated page or screen size. If you begin typing a paragraph or long sentence in an editor, it will often continue on the same line for as long as you keep typing, without breaking the text onto the next line. Source formatting, or the style of line breaks and indentation you use to keep your source readable, is a necessary skill that you will develop over time as you work with your editor.
Line Breaks
There are a couple of different options for handling line breaks. Some editors will create so-called soft breaks, which visually wrap text onto new lines in your text editors particular view of the le. But soft breaks are not saved with the le itself. If you view the les source in a browser, it will appear as one 10-mile-long line. The other option is to create hard breaks by hitting the Enter/Return key on your keyboard. Hard breaks are special characters that are stored
139
in a le; these break the lines of your source for anyone viewing it (including people who choose the View > Source option in their Web browser). It is tradition to put hard breaks in source les after 80 characters, but running out to 100 characters is ne, too. Line length is, in source formatting as in page design, a matter of reading comfort. Your editor can probably set up a visual onscreen guide to show you where the 80or 100-character mark is, so you know when to hit Return.
LF, CR+LF, AND CR: THE MOST BORING SIDEBAR IN THE BOOK
So I have been telling a little bit of a lie so far. There is one thing that you cannot see in a text editoror that you usually dont see, unless something has gone very wrong: the special character that different operating systems put in text editors when you hit the Enter key for a line break. This is primarily a Windows issue; the details are below, but sufce it to say that the preferred break for les destined for the Web is the linefeed character, LF. It is preferable because it works well across all operating systems, including and especially the Linux or Unix-like operating system that will probably be run by your Web host, as Chapter 5 suggested. Most Windows editors, including Notepad++, allow you to specify what character should be used for new lines. In Notepad++, go to Settings > Preferences and then nd the New Document/Default Directory tab. Make sure you choose Unix as the default format. If you open up older les, you can always choose Edit > EOL Conversion, and change the current le to Unix. (EOL means end of line.) Doing so will make work easier for you and your collaborators if you move, or might move, between Windows, Mac OS, and Linux. If youre struggling to stay awake, you can skip back to the main text. But if youre interested in a little history/trivia, here goes: Carriage Return and Line Feed, or CR+LF, is the double character inserted by Windows editors; what it results in most often is text les appearing double-spaced on LF systems, such as OS X and Linux. (CR by itself is basically ancient, although if you want to re up your old Apple II or even a Mac OS 9 machine, youll nd a piece of living history.) For those troubled few who nd this discussion fascinating, consult the Wikipedia page for Newline: http://en.wikipedia.org/wiki/ Newline
140
You can also put in breaks whenever it helps make your source more readable. Except in a very specic instance (the <pre> tag), white space (spaces, tabs, hard breaks) in XHTML source (Figure 12.6) is not reected in the browsers rendering of your page (Figure 12.7). (This means that inserting a tab or ve spaces at the beginning of a paragraph will not indent your paragraph; to indent paragraphs, use the CSS text-indent property.) Format your source in the source view of your editor however youd like, it will render the same in a browser view.
Indentation
Another means for making source more readable is to use indentation. Some text editors will insert multiple spaces for each strike to the Tab key, while others will insert actual tab characters. Look through your editors preferences, as you can change this to whatever you wish. Tab characters are easier to delete and reformat than a whole bunch of spacesplus its usually possible to tell the text editor how wide to
Figure 12.6. The same paragraph, formatted three different ways using tabs, spaces, and line breaks in the source.
141
Figure 12.7. Despite the differences in source formatting shown in Figure 12.6, all three paragraphs display exactly the same in the browser view.
142
display a tab. But you can nd passionate, almost religious discussions across the Web where people debate indents-as-spaces versus indentsas-tabs. (The RPK is indented using spaces, by the way.) Whether by tab characters or spaces, indentation makes XHTML more readable by making nested tags even more clear; here is a heading two and paragraph tag nested inside of a division tag:
<div class="tip"> <h2>Indentation Makes Source Readable</h2> <p> However, some text editors require you to do your indentation manually. </p> </div>
Likewise, indentations and line breaks can help make CSS source more readable:
body { font-family: Helvetica, Arial, sans-serif; font-size: small; }
Some Web designers even like to indent selectors to visually track which styles appear within other styles:
div#content { width: 500px; } div#content h2 { font-size: 26px; } div#content p { font-size: 14px; } div#content p a { color: green; }
How your format the source for your XHTML, CSS, and JavaScript is up to you, because in most cases, it has no impact on how your pages display. But it will have a major impact on your ability to collaborate with others, and even how easily you are able to read and understand your own source later.
143
Every computer language has some sort of syntax for writing comments that is meant for humans, not computers. To help make your pages more sustainable, its wise to get into the habit of commenting on your source. Not only will comments make it easier for you to edit your pages in the future, but it will also help you to think through what you are doing. If you describe, in the comments, what your source means and what you intend it to do, you will deepen your understanding of how Web languages work. So in addition to formatting your source for readability using line breaks and indentation, you can also write comments to your source. In XHTML, comments begin with <!-- and end with -->. For example:
<!--Here is a comment in XHTML.-->
XHTML comments are not rendered on your page in the browser, nor is the browser affected by their contents. (However, it is actually the two hyphens, --, that close the comment, so do not use a double-hyphen in your comment text itself. This is a hard habit to break for those of us who use two hyphens in email to mimic an em dash.) CSS and JavaScript both use a slash-star (/*), star-slash (*/) pattern to start and end comments:
/*Here is a comment in CSS*/ /*Here is a comment in JavaScript*/
Here are some general tips for writing useful comments: Write comments as though you were trying to teach or explain what youre doing to someone else. Many teachers will tell you that they never really learn a subject until theyve taught it to
144
others. Writing comments that attempt to teach and explain will help others who might look at the source of your pages and it will help your future self, who will probably have forgotten why some feature of the page was written to begin with. Provide human-readable information to accompany information for the computer. In CSS, for example, you usually specify colors by numberseither hexadecimal or RGB (see Chapter 10). But few of us can remember that #FF3399 is hot pink. Some designers even write color references at the top of their CSS so they know which numbers to write:
/* Colors in #339900 #FFCC33 #993300 */ this Design: Deep Green Sandy Orange Deep Red
Be careful about referring to line numbers in your comments. Consider a comment like:
<!--This closes the <div> tag from line 15:--> </div>
It will only be true so long as no lines are added or removed before line 15. A better approach is to refer to actual structural features that can be found using a text editors search function:
<!--This closes the <div id="gallery"> tag from above:--> </div>
Ask questions or set to-do lists for yourself or others you are working with. Having a question or to-do item in with your source is just more convenient than having it stashed away in a notebook or an email.
<!-Can someone please check the XHTML
WRITING WITH SOURCE IN A TEXT EDITOR below? It's not validating for some reason, but I don't understand the error output from the validator. -->
145
When you update the source, update the comments. Like all commenting practice, it can be time-consuming to update the explanation that goes with each change you make. But the long-term benets to your sanity outweigh the inconvenience. Trust me.
Yes, you could just delete the problem source. But by just commenting it out, you prepare for testing and possibly further revision, while keeping the Web browser from reading problem source as you test. (Although eventually, if you determine that the source youve commented out will never be revised, its probably better if you delete it.)
NEXT STEPS
Working with your text editor is, like all aspects of Web writing and design, an ongoing process of learning. As you work on your pages and read through the remainder of this book, keep in mind the practices suggested in this chapterparticularly indenting and formatting your source, and using comments to explain to yourself what it is that you have written. The remaining chapters in this section of the book get into the specics of individual components of page writing and design. We will set
146
up and inspect some basic page metadata before delving into page content and text styles. The chapter on branding will look at the headers and footers that appear on all of your pages and some interesting CSS techniques for image replacement and hiding elements. In the navigation chapter, we look at how to build a usable site navigation (you will also want to revise it as you work through the site architecture chapter, Chapter 20). The chapter on page layout brings the content, branding, and navigation elements together, and the chapters on multimedia and performance and interaction will look at ways to enhance your pages for cutting-edge deviceswhile still meeting the accessibility needs of all users.
CHAP TE R
13
Page Metadata
Well-written XHTML pages include a variety of metadata, which is information about the contents of each of your pages. Search engine spiders, Web browsers, and even sites like Facebook and Diigo can make use of your pages metadata, which in turn improves your site visitors experience. This chapter looks at essential metadata for describing the contents and construction of your sites pages; there are some additional, advanced metadata topics for sharing your content in Chapter 24.
148
page that lists all of the language codes according to the two-letter ISO 639-1 and three-letter ISO 639-2 standard, if you are writing a page in a language other than English.1 If both two-letter and three-letter codes are listed for the language you are writing in, the W3C species that you must use the two-letter code.2) So, a metadata-rich <html> tag opening a Web page written in English will look like:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
The RPK contains one additional attribute-value pair on the <html> tag: a unique ID whose value should be the domain name of your Web site. For example, my Web sites domain is karlstolley.com; on all of my sites pages, I add a unique ID of karlstolley-com, replacing the dot with a hyphen, as dots are not allowed in ID or class names. So, my completed <html> tag looks like:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" id="karlstolley-com">
Adding that unique ID, known as a CSS signature,3 on each of your pages will allow visitors to write custom CSS to change how they view your site, often by using a browser plugin such as Stylish for Firefox.4
PAGE METADATA
149
MIME type information with other computers and software, such as Web browsers, so that content can be displayed correctly and by the appropriate software application. The basic HTML MIME type is text/html and can be used with XHTML. (Note that in XHTML, the content type should actually be application/xml+xhtml; however, because certain browsers do not understand that content type, the content type must remain text/ html for the time being.) Your Web pages should all have a <meta> tag that reads:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
The other crucial value in that tag, in addition to the text/html MIME type, is the UTF-8, or Unicode, character set, or charset. Older Web editors often set a default character set of ISO-8859-1, which is a limited set of characters used by older computers (see Figure 13.1). UTF-8 is a much larger character set and lets you use fancy
Figure 13.1. Mismatched character sets cause special punctuation marks and symbols to display as clusters of garbage characters.
150
typographers quotes (instead of straight quotes), em dashes, and other character enhancements that word processors often add to text (see Figure 13.2). UTF-8 also makes it possible to write special characters from languages other than English.
Figure 13.2. By specifying the UTF-8 character set and setting your editor to properly encode the XHTML le (UTF-8 without the Byte Order Mark, BOM), you can include text with special characters without having to use XHTML entities.
PAGE METADATA
151
Character Entities
The XHTML specication allows for particular character entities, which a browser will display as a special character. To display a copyright symbol in the browser, for example, you could write the XHTML entity ©. However, XHTML entities are worth avoiding for a few reasons: rst, they are not easy to remember. With a good entity reference,6 that may not be a problem. But entities may make your content less portable, particularly if you are reposting your content as an RSS feed. RSS is limited to a much smaller collection of entities; any XHTML entities beyond that collection will probably cause your feed to malfunction. With the UTF-8 character set, you do not need to use XHTML entities except the three listed below. You can just use the character directly in your source; most word processing programs will create these characters automatically (such as typographers quotes, or even the copyright symbol if you type (c)). For other characters, you can go to the character map or other listing of characters on your computer. The only case where you must use entities is for angle brackets, which would be interpreted as part of XHTML tags, and the ampersand, because it is used to indicate the start of an entity (using the ampersand by itself with throw an error in the XHTML validator, too). These, then, are the three characters for which you must use entities:
< to display < > to display > & to display &
There are also entities for straight double quotation marks, ", and the straight apostrophe, '. You rarely need to use those, although they are essential for use in JavaScript or in your <meta> tags for sharing (see Chapter 24) unless you use the typographers (sometimes called smart) quotation marksalong with the UTF-8 character set.
152
tabbed browsing), and in browser bookmarks. The content of the <title> tag is also the clickable link in the results list of most search engines. The title tag should contain both the specic title of each Web page plus the name of your site. Which order you put them in (page title then site, or site title then page) is a matter of personal preference. I prefer to put the unique page title rst, followed by the site name:
<title>Title Bar Example Sustainable Web Design </title>
The reason for the page-before-site order is that the contents of <title> tags may be shortened in browser tabs, and I prefer to have the unique part of the page title visible, particularly if someone were to have more than one tab opened to a page on my site. Not that that happens with my site, but its important to dream. (See Figure 13.3.)
Figure 13.3. The contents of the <title> tag appear in Firefoxs title bar and on the tab.
PAGE METADATA
153
154
preference is to specify the location explicitly in the link tag. Favicons are important enough to site branding that I prefer not to leave their appearance to default browser behaviors and therefore to chance. So to explicitly state the location and type of your favicon, your <head> should include the full URL to your icon in a <link> tag:
<link rel=" icon" href="http://example.com/ favicon.png" type="image/png" /> <!--For Internet Explorer; no type must be specied--> <link rel="shortcut icon" href="http://example.com/ favicon.ico" />
If you opt to use PNG or another format, it must have the proper MIME type associated with it, e.g., image/gif for GIF les.
PAGE METADATA
155
le once, no matter how many pages on your site they view. Once the .js or .css le has been downloaded, the browser caches the lemeaning it makes a copy on the visitors computer. That speeds up the performance of your site, because only the XHTML and content of subsequent pages have to be downloaded. On slow Internet connections or mobile devices, shared design and scripting les dramatically improve your sites performance. However, even though the concept behind linking to CSS and JavaScript les is the same, they each use different XHTML.
Linking to CSS
Links to CSS are created using the self-closing <link /> tag with some special attributes: rel="stylesheet" tells the browser the link is to a style sheet and type="text/css" species that the style sheet contains CSS instructions (and yes, text/css is the MIME type for CSS). The href attribute points to the style sheets location, while the media attribute allows you to specify whether the style sheet is for the screen, for printing, or other formats. A complete link to a style sheet for screen design looks something like:
<link rel="stylesheet" type="text/css" href="/css/style.css" media="screen" />
Note that you can load multiple style sheets on a single XHTML page just by adding additional link tags in the <head>; for example, the Rapid Prototyping Kit (RPK) loads three different style sheets for the screen using this method (see Chapter 11).
Linking to JavaScript
Linking to JavaScript les is done using the <script> tag (as with the on-page method of writing JavaScript described above). However, when linking to external scripts, the <script> tag opens and closes but remains empty. Like the <link /> tag for CSS, it is essential to tell browsers what type of script youre linking to. In one of the little idiosyncrasies of XHTML, however, to link to the script, you must use the src (source) attribute instead of href:
156
Again, note that there are opening and closing tags for <script>, even though they surround no content.
You can also use the different elements from the navigation as classes for other site pages. For example, a resume page would probably be linked from a Resume item in the site navigation; that page could take <body class="resume">; if your site has a portfolio area, all of those pages could take <body class="portfolio">. Chapter 15 notes that you can even use body classes as part of waynding (see Chapter 7) by styling the navigation according to which area of your site a user is viewing. Chapter 19 will also show how JavaScript can automatically add additional classes on the <body> tag; the RPK adds a hasjs class to <body> if a user has JavaScript enabled:
body { /*Body styles for all CSS-enabled users*/ } body.hasjs { /*Body styles for CSS- and JavaScriptenabled users*/ }
You can also use JavaScript to add other classes for users viewing sites on wide screens; that class can be yet another selector in CSS that
PAGE METADATA
157
enables you to style your page to take advantage of wide screens or other viewing conditions. Remember, though, that its always best practice to design your pages to be accessible and usable without JavaScript. Once you have done that, you can go back and progressively enhance your pages, so long as they degrade gracefully (see Chapter 6).
NEXT STEPS
This chapter has covered some of the basic metadata that should appear in your XHTMLs <head> area, as well as a class on the <body> tag.; Chapter 24 looks at a few additional things to place in the <head> to make your content easier to share. In the next chapter, though, we will get to writing something more interesting: the visible content of your pages, beginning with the branding shared across all of your pages.
NOTES
1. Library of Congress, Codes for the Representation of Names of Languages, http://www.loc.gov/standards/iso639-2/php/English_list.php 2. W3C, Language Tags in HTML and XML, http://www.w3.org/Inter national/articles/language-tags/RFC3066.html 3. Eric A. Meyer, CSS Signatures (September 28, 2002), http://archi vist.incutio.com/viewlist/css-discuss/13291 4. Jason Barnabe, Stylish, Add-ons for Firefox, https://addons.mozilla.org/ en-US/refox/addon/2108 5. Webmaster Toolkit, MIME Types, http://www.webmaster-toolkit.com/ mime-types.shtml 6. Elizabeth Castro, Character Entity References in HTML 4 and XHTML 1.0, HTML, XHTML, and CSS, 6th ed. (2002), http://www.elizabethcastro .com/html/extras/entities.html
CHAP TE R
14
Page Branding
Branding identies a page as belonging to your site. Although branding is usually associated with logos and color schemes, the branding of Web pages also depends on the structure and design of the whole page, including headers and footers that are consistent from page to page. Navigation (covered in the next chapter) also plays a role in branding, both visually and by representing your site as having a sensible, usable architecture. The terms header and footer come from print design, where they typically refer to the very top (header) and bottom (footer) of a page. However, while structurally your header appears at the beginning of your XHTML source and the footer at the end, CSS enables you to create page designs that display the header and footer in other places. Regardless of their location on a designed page, the header and footer serve important and unique branding functions: The header is the place to provide a consistent label for your pages, usually by writing your site name in an <h1> tag. The header is also a place to offer a logo or logotype (your sites name presented in a unique font, perhaps as an image) and to have that logo link back to the home page of your site. Most sites also clarify their purpose to visitors by including a short description of the site, also known as a tagline. Finally, to aid accessibility, the header should provide a list of links for visitors using devices with limited or no visual display to skip to the navigation and perhaps other areas of your pages. These links make the page more accessible on mobile and assistive devices, but might be hidden from view on fully graphical browsers.
160
The footer often features site credits and perhaps a link to a Creative Commons license, which makes it easier (and legal) for people to share and reuse your content, and therefore build your reputation and identity across the Web (see Chapter 24). The footer may also be used to provide links to validate your XTHML and CSS and perhaps to promote any libraries or software you use to create and maintain your site. For strong branding, your header and footer should be structurally and perhaps visually identical across all of your pages. Some Web pages may have CSS that presents a more prominent header area, such as on the home page of a site. But its generally a good practice to design most, if not all, pages headers and footers the same.
THE HEADER
The most basic page header will include the title of the site, a description or tagline, and accessibility links for jumping to different areas on the page.
<div id="header"> <h1> <a href="http://example.com/" rel="home">Site Title</a> </h1> <p class="tagline">Site Description</p> <ul class="accessibility"> <li><a href="#navigation">Jump to Navigation</a> </li> <li><a href="#content">Jump to Content</a></li> </ul> </div>
In the Rapid Prototyping Kit, the header appears in <div id="header">, which is the rst major structural unit of the XHTML source inside the <body> and <div id="page"> tags.
Site Title
The site title belongs in an <h1> tag and should probably be the only use of the <h1> tag on your site. For all other headings, use <h2>, and <h3> for subheadings (see Chapter 16). If you are building a site to promote yourself, your name is a great choice for a site title.
PAGE BRANDING
161
However, if you are primarily running a blog on your site, you might use the title youve given to your blog (see Chapter 22). If youre creating a page for a business, club, or other organization, then use that name for the site title. Its unnecessary to add obvious phrases like Home Page of . . . or Web site for . . . to the site title. Placing your name or that of your organization or business in a heading-one tag may also help your rankings on Google searches for your name or organization. The site title in the header area complements the <title> tags in your pages <head> area, while adding a visible title on your page, too. In addition to the <h1> tag, its an established convention on the Web to also link the text of the site title to the home page of your site. Usually, this link will include the full URL to your home page. Anyone who wants to return to your home page can simply click on your site title in the branding area. So for example, on my Web site, I have:
<h1><a href="http://karlstolley.com/">Karl Stolley </a></h1>
This is one of the only cases where writing a link with your full site URL is necessary, as it lets you do some unique things with your site title, such as add additional information about its home page. For example, you can use the rel-home microformat to indicate that the link on your site title points to your home page:1
MICROFORMATS
XHTML describes the structure of content, but XHTML on its own has no capacity for expressing the meaning of content. For example, a link to a Creative Commons license is indistinguishable from any other kind of link that appears in <a href=" ">. Microformats change that. A link to a Creative Commons license can include rel="license" in the <a> tag, indicating to search engines and computers that understand the rel-license microformat that the link not only takes someone to another destination, but that it actually means that the page where the link appears is licensed under a specic Creative Commons license. You can learn about many other types of microformats at Microformats.org.
162
Accessibility Links
Because the RPK places the site navigation in the list <ul id="navigation"> (see Chapter 15) and page content in <div id="content"> (see Chapter 16), the accessibility links in the RPK
PAGE BRANDING
163
header point to #navigation and #content. Those links, known as fragment identiers, allow mouseless users (such as people on mobile phones) as well as users relying on screen readers to quickly jump to different areas of your pagewithout having to scroll through or to listen to unnecessary information. One of the features of unique IDs is that you can reference them in URLs that instruct Web browsers to automatically scroll to a specic part of the page. So, for example, if you have your navigation marked with id="navigation", the URL http://example.com/home .htm#navigation will instruct a Web browser to scroll to that portion of the page (see Figures 14.1 and 14.2).
Figure 14.1. Accessibility links are important in mouseless, text-only environments, as in this view of a page as displayed in Lynx.
164
Figure 14.2. Activating the Jump to Navigation link takes Lynx users straight to the navigation.
out as you learn to design with CSS while you craft the branding for your site.
The trouble with that method is that display: none; may also hide the links from screen readers. An alternative method to hide the accessibility links from screen view (while keeping them accessible to screen readers) is to position the accessibility links absolutely, which removes them from the document ow (see Figure 14.4; Chapter 17 provides additional discussion of document ow). Then, setting the left: property to an extremely large negative pixel value basically
Figure 14.3. The accessibility navigation is outlined here in black, just to show the space that it lls by default.
Figure 14.4. Positioned absolutely, the accessibility link area shrinks to t the text of the links, and the rest of the page jumps up to where the accessibility links were.
166
Figure 14.5. A large negative left value effectively hides the accessibility navigation from view and does not affect the remaining visible page elements.
moves the accessibility links way off to the left of the screen, hiding them from view (see Figure 14.5):
ul.accessibility { position: absolute; left: -10000px; /*Remove from document ow and prepare for positioning*/ /*Move way off to left; browser will not create a horizontal scroll bar*/
is a very basic way to add the smallest bit of visual interest, while distinguishing the header from the rest of your page (see Figure 14.6).
PAGE BRANDING
167
Figure 14.6. Adding a border to the header adds a bit of visual interest and distinguishes the header from the rest of the page.
You might echo this simple design choice by adding a border to the top of the footer area, as described below. Another simple design choice is to specify a background color on div#header and, if needed, a contrasting color on the text:
div#header { background-color: #000; /*Set the background to black*/ color: #FFF; /*Set the text to white*/ }
As you can see in Figure 14.7, because no specic background color has been set on the site title or tagline, they appear as transparentsharing the black background set on div#header. There is nothing wrong with using borders and background colors to design a basic header; but sites that want to establish an even more unique design often employ background images, which behave very similarly to background colors in that descendant elements (like the site title and tagline in the header) appear to have transparent backgrounds. Figure 14.8 shows the header with a simple background image
168
Figure 14.7. A background color on the header appears to be shared by the site title and tagline, which are transparent (unless assigned their own background color).
that is only a few pixels wide, but that is tiled horizontally to ll the entire width of the header, e.g.,
div#header { background-image: url('gfx/header-tiledbackground.png'); /*Load the image*/ background-repeat: repeat-x; /*Tile the image horizontally only*/ background-position: bottom left; /*Always show the image at the very bottom*/ background-color: black; /*Background color in case image is ever broken*/ color: white; /*Text color set to white;*/ }
Even more complex effects can be achieved by designing background images that anticipate other content areas; as of CSS 2.1, only one background image can be attached per XHTML element, so to have, for
PAGE BRANDING
169
Figure 14.8. The border at the bottom of this version of the header is achieved by tiling a background image horizontally. In Chapter 17, it will be clear why this is done with an image, rather than a CSS border property.
example, a unique top and bottom image on the content area, use other elements and some of the CSS positioning tricks discussed in Chapter 17.
Then, to size the text to appear larger, just work with the h1 descendant selector of div#header:
div#header h1 { font-size: 200%; }
170
Figures 14.6 and 14.7 show those styles as they appear on the site title. Of course, with something as unique and important as the site title, simple styles like this are often not enough to uniquely and memorably brand your pages. To add a logo or logotype, you can use one of a number of CSS image replacement techniques. What image replacement does is use CSS to set a background image on an XHTML element together with some method of hiding the XHTML text from view. One way to do this is to load the image in CSS, set height and width of the XHTML element its loaded on to match the image (in the RPKs case, using the div#header h1 a selector, so that the image is clickable), and then set the CSS text-indent property to a large negative number to effectively pull the text off the screen (see Figure 14.9). That approach should keep the text accessible to screen readers. For example,
div#header h1 a { background-image: url('gfx/logotype.png'); background-repeat: no-repeat; /*Don't tile*/ display: block; /*Show anchor as a block*/ text-indent: -10000px; /*Pull text off of screen*/ }
PAGE BRANDING
171
Figure 14.9. Image replacement on the site title; a large negative text indent pulls the XHTML text off of the screen, leaving the background image unobstructed. Note the tagline text running along the bottom; it will be xed in the next section.
THE FOOTER
Closing out the RPKs branding XHTML is <div id="footer">.
<div id="footer"> <p class="credits"> Site information, credits, license. </p>
172
Figure 14.10. Adjusting the left margin and top padding on the site tagline gives it a more prominent place in the header.
<!--These links only work on live, web-available sites:--> <ul class="validators"> <li><a href="http://validator.w3.org/check? uri=referer" title="Validate this page's XHTML">XHTML</a></li> <li><a href="http://jigsaw.w3.org/css-validator/ check/referer" title="Validate this page's CSS"> CSS</a></li> </ul> </div>
Its useful to include information in your footer about the design and content of your pages. A line such as Page design and content by Jane Smith. may be added. If you wish to allow others to use your content or design, you can also add a link to a particular Creative Commons license (see Chapter 24). For information about copyright statements, you should read Chapter 4 of Title 17 of the United States Code2 and
PAGE BRANDING
173
Chapter 37 of the Code of Federal Regulations3 and consult with a lawyer for additional details.
Reusing the border image from the header ties the page to-
Figure 14.12. The Creative Commons license image is loaded in XHTMLs image tag, but CSS controls its presentation by displaying it as a block on its own line.
PAGE BRANDING
175
of opting for an image tag is that the image will print along with your content (by default, background images will not printand some browsers do not allow background image printing at all). A printed license icon would help clarify how your content is licensed, even in paper form. Even when images are loaded in XHTML, CSS allows you to control their position with respect to other elements. In Figure 14.12, the comparatively large CC license icon is offset from the rest of the footer content using a little bit of CSS (see Chapter 17).
NEXT STEPS
Once you have written your header and footer, save your my-proto type.htm le and screen.css if youve also written styles for your work so far. The content and structure of your header and footer should remain more or less the same across all of your pages, although you can use a class on the <body> tag, as Chapter 13 suggested, as a hook to style any differences on particular pages. The next chapter will cover another piece of content that should be consistent from page to page across your site: the navigation.
NOTES
1. Microformats.org, rel-home, http://microformats.org/wiki/rel-home 2. Copyrights, U.S. Code 28, 401 et seq. 3. Patents, Trademarks, and Copyrights, Code of Federal Regulations, title 37, 202.2.
CHAP TE R
15
Navigation
Navigation is a key feature found on almost every Web site. Although structurally it is nothing more than a list of links, site navigation can be designed many ways so long as it simplies how users move around the different areas of your site. And even if users do not click on every item in your navigation, it should still give them a sense of what your site contains and how its contents are organized. It can also contribute to waynding, by highlighting the navigation element that represents the section of the site a user is currently viewing. While it may be tempting to build a navigation that includes a link to every single page on your site, if you have too many items in your navigation, it may become less usable for your users. One way to begin thinking about the design of your navigation area is to compare a Web sites navigation to the signs over the aisles at your local supermarket. Supermarkets dont list every single item for sale in the aisle, but rather general types of items (soup, pasta) or categories of items (cleaning supplies, baking). If the signs did list every single item, it would probably take shoppers longer to read all of the signs in the store than it would to walk the aisles, one by one. But there is another important lesson about navigation that can be learned from supermarkets: signage on their aisles probably does not do much to entice shoppers to buy things. Neither do navigation areas encourage visitors to explore your Web site. To get people to shop beyond their lists or habits, supermarkets often feature sale displays at the end of aisles and even place staple groceries, such as milk, at the very back of the store. Its important to complement your sites navigation area
178
with features like promotional sidebars to encourage exploration; even a well-designed navigation area may not be enough to interest all visitors to look around.
NAVIGATION
179
Note that in that example, with the exception of Home, the navigation labels match the le names in the links. Navigation item labels that match your le names will help keep your navigation manageable as you build your site. But they will also inspire your visitors condence that the label in the navigation is reective of the page it links to. The anchor tags in the navigation also have unique IDs that match the labels but are prexed with nav-. Those will be used with the CSS to enhance waynding in conjunction with classes on the <body>, which Chapter 14 suggested including. Whenever I design Web sites, I make it a personal challenge to try and develop single-word navigation labels. Single words are easier to style, particularly in horizontal navigation areas, because you can pack navigation items closer together. Navigation labels with multiple words necessarily have spaces between the words, so the space between individual navigation items must be noticeably larger. Sometimes multiple words are unavoidable. But its always possible to avoid pronouns that often appear in navigation items, such as
180
my, us, our, and so on. My Resume is redundant, if its your resume on your site; Resume will sufce. For groups and businesses, About and Contact will imply an us, making Contact Us similarly redundant. For a personal Web site, navigation might include links to key pages, such as a resume, a portfolio of work, an about/biography page, and perhaps a page of contact information. And in addition to a home page link on your logo or branding (see the previous chapter), its never a bad idea to include a navigation link to the main page of your site. Whether you label this Home, Overview, or Main is up to you, but Home is short and sweet and something of a convention on the Web. Business Web sites will want to include their core products or services in the navigation, as well as an About and Contact page. Contact pages on business sites are not just for new or potential customers, but also for current customers who may have some sort of issue that needs to be resolved. Make it easy for all customers to contact you by placing a link right in the navigationrather than off of a page deeper in the site.
NAVIGATION
181
By increasing the padding on anchor tags (and by displaying anchor tags as blocks rather than their default inline display), it is possible to create much larger clickable areas:
ul#navigation li a { display: block; /*Treat links as blocks*/ padding: 20px; /*Padding is also clickable*/ background-color: gray; }
Larger clickable areas make using your site navigation less laborintensive for visitors, because they can be much sloppier with their clicking. In Figure 15.2, you can see that hovering the mouse changes the entire boxs color. That change in background color is achieved with the :hover pseudo-class; by adding the :focus pseudo-class to your selector, the hover effect should be visible for keyboard users tabbing from link to link, too:
ul#navigation li a:hover, ul#navigation li a:focus { background-color: white; }
Figure 15.1. Even though there is a generous box for each navigation item, only the text is clickable.
Figure 15.2. Using CSS, each navigation item has a much larger clickable area, and is therefore much more permissive in terms of where users can click.
NAVIGATION
183
EASY ON THE
:HOVER
STYLES
Dont go crazy adding a lot of styles to the :hover selector. Mouse pointers already change over links, so there is already some indication that an element is clickable. At the same time, hover properties are helpful in two situations. The rst is when clickable elements are very close to one another, such as in a navigation bar; a hover effect can clarify which navigation item will actually be activated upon clicking. The second is when someone is using a keyboard to navigate links, and therefore does not benet from a pointer that changes to indicate whether an item is clickable. (Some browsers will provide a dotted border to indicate clickable items for keyboard users, but the border is sometimes difcult to see.) Hover properties that change text or background colors generally work well, as do hovers that change background images by altering the backgroundposition: property (see the books companion Web site, http://sus tainablewebdesign.com/book/). What you should avoid at all costs are hover properties that change the size or width of contextual link text or navigation elements; this includes not just font sizes, but bold and italics as well as border widths, padding, and margins. Those shifts may cause all of your page content to jump around, particularly for contextual links in your sites content.
184
body.home ul#navigation li a#nav-home, body.about ul#navigation li a#nav-about, body.resume ul#navigation li a#nav-resume { background-color: white; }
The links in that navigation will still have a white background when moused over or focused via the keyboard. But on the home page, the link to home in the navigation will always have a white background; on the about page, the about links background will be white, and on the resume page, the resume links background will be white. In each case, the design simply tells users You are here through a tiny visual enhancement, using bits of XHTML structure that are already in place. You can see this technique in action on the navigation at this books companion site, http://sustainablewebdesign.com/book/.
NAVIGATION
185
navigation onto a second line is usually disastrous: readers dont know whether to move their eyes horizontally or vertically, and they may wonder whether the items in the second line of navigation are less important. If you only have a few navigation elements, say three or four, and they all use very short words, they will display nicely horizontally, on a single line. But if you wish to add many more navigation elements, a second line may becomes necessaryand will take a visitor even longer to scan. There are a number of methods for displaying list items in a horizontal line; the simplest and most exible is to use oats. When an element oats in CSS, it remains part of the document ow, but allows other elements to appear next to it horizontally. By oating all of the items in a navigation list and maximizing the clickable area, a simple horizontal navigation can be built in CSS like this:
/*Horizontal Navigation, Float Method, Automatic Width*/ ul#navigation { overow: hidden; /*Necessary style for best handling oats*/ } ul#navigation li { oat: left; /*Float items to the left*/ display: inline; /*Fix a oat issue in older IE browsers*/ margin-right: 5px; /*Put some space between items*/ } ul#navigation li a { display: block; /*Maximize clickable area*/ padding: 5px 10px 5px 10px; /*Generous padding on top and bottom, less on right and left*/ background-color: #CCC; /*Background color for the items*/ }
186
Figure 15.3. A horizontal navigation bar with buttons of different widths, depending on the length of the label text.
That particular method will create items or buttons (as they appear) of varying width, depending on how long the name of the label is (Figure 15.3). For uniformly sized clickable areas, one can adjust the example above by adding a xed width to the ul#navigation li selector (see the rendering in Figure 15.4):
/*Horizontal Navigation, Float Method, Fixed With*/ ul#navigation li { width: 100px; /*All buttons 100px wide*/ oat: left; display: inline; margin-right: 5px; }
By adding text-align: center; to the style declaration for ul#navigation li, you can regain the centered-text appearance of the variable-width buttons from Figure 15.3, as in Figure 15.5 One word of caution regarding oated, horizontal lists, though: if your layout is exible, or if someone increases the text size on a page,
Figure 15.4. A horizontal navigation bar with buttons of the same width, and the text aligned left by default.
Figure 15.5. A horizontal navigation bar with buttons of the same width and centered text.
188
your navigation links may be broken onto a second line, making your navigation less usable by reducing how quickly someone can scan it with their eyes. Be sure to test your navigation under a variety of conditions, including multiple screen and font sizes, and on different operating systems.
NEXT STEPS
Navigation is a simple list of linksand styling that list is itself not too difcult. By maximizing the clickable area of a short list of items that reect your sites content and organization, you will have the foundation for visitors to move quickly through your site. With your branding and navigation drafted, you should now have the essential, repeated parts of your page in your my-prototype.htm le. Rather than starting from scratch, you can now start writing each new page of your site with your branding and navigation ready to go; just open my-prototype.htm and choose Save As. . . and immediately name it about.htm or index.htm or whatever page it is that youre about to build. (See Chapter 21 for ways to repeat your branding and navigation dynamically across all of your pages, in case you need to make changes to them.) The next chapter turns to writing the text content of your pages, including how you can develop your own style guide for writing markup to make writing with XHTML simple and even fun. Unlike branding and navigation, of course, content differs from page to page, and so it requires a writing approach that is more exible, but that a style guide can make more consistent.
CHAP TE R
16
Text Content
Once you have established the XHTML structures for your page branding and navigation, you can reuse them across all of the pages of your site, perhaps changing the class on the <body> tag (Chapter 21 shows how to dynamically repeat the branding and navigation across all of your pages, to simplify site-wide changes to them). Where you spend most of your time creating new markup for your pages is in the content portion of your page. Branding and navigation can be structurally and visually constant across pages, but the structure of text content is almost always unique (unless youre writing a Web site full of ve-paragraph essaysand please dont). This chapter walks through approaches to marking up your content in XHTML. It also suggests developing some basic site typography for your pages using CSS to create a site style guide to simplify your markup and design.
190
on a site, so that pieces of content are marked up consistently and uniformly. The simplest way to write your style guide is to put together a page that includes all of the structural elements you use to mark up your page content, and provide a sample rendering using the sites actual CSS by linking to the sites CSS le. Then, any changes to your CSS will also change the style guides appearance. Save your style guides XHTML le as style-guide.htm for easy reference. While you can use Lorem ipsum text to show off the examples, its good practice to use the sample text to convey what kind of content should be marked up as paragraphs, lists, or any other structural pages for your site. That will help it serve as a refresher for your memory and as guidance for any collaborators. The example style guide in Figure 16.1 also shows the XHTML markup required for each site style. Different pieces of this example style guide will be shown in gures throughout the chapter.
Figure 16.1. A site style guide can remind you and your collaborators of the available content styles, and even what the XHTML is to achieve them.
TEXT CONTENT
191
Marked up in XHTML, that little chunk of text could be described accurately with the heading, paragraph, and list tags:
<h1>Primary Colors</h1> <p>There are three primary colors that occur in nature. They are:</p> <ul> <li>Red</li> <li>Yellow</li> <li>Blue</li> </ul>
Headings
There are six levels of headings in XHTML. <h1> is a top-level heading; <h2> a subheading; <h3> a sub-subheading, and so on. Stylistically, its
192
usually better to limit your use of <h1> to once or twice a page; <h2> can be used often, as can <h3>, provided that <h3> is used for subheadings that separate content under an <h2>. When using headings, though, remember that their purpose is to break up long stretches of text with meaningful labels. <h1> might provide the site title (as in the RPK). <h2> can mark up the titles of individual pages, whose major sections are subdivided by <h3> tags; the sections labeled by <h3> tags could then be broken up further by <h4> tags. Consider a concrete example. Imagine that John Smith used headings to mark up his resume; if we took away all of the content and left only the headings in his resume, we might see something like:
<h2>Resume for John Smith</h2> <h3>Objective</h3> <h3>Work Experience</h3> <h4>Industry</h4> <h4>Government</h4> <h3>Software Skills</h3>
Now its important to note that the indentations are only to enhance readability of the XHTML source code (see Chapter 12). Particularly for the two <h4> tags, indents also illustrate that the heading tags are used for further subdividing content, not for enumeration. (I once had an undergraduate student who kept adding more and more numbers to his headings each time he used one. When I told him there was no such thing as an <h27> tag, he took the news pretty hard. The most minor subheading in XHTML is <h6>.) Figure 16.2 shows a sample style guides styling of <h3>.
Paragraphs
There is only one paragraph tag in XHTML: <p>. You should use the paragraph tag to describe actual paragraphs of textand nothing else. If something is structurally a heading, do not use the paragraph tag. I also often see beginners misuse the paragraph tag like this:
<p><h2>This is So Wrong</h2></p>
Im not quite sure why beginners tend to do that. I suspect it may be due to word processors displaying the paragraph mark, , after every
TEXT CONTENT
193
Figure 16.2. This sample style guide runs <h3> tags in Georgia font (the rest of the body text is Arial) with a bottom border for visual interest.
break (including headings and lists). But reason it out, XHTMLstyle: if something is a heading, its a headingnot a paragraph. Paragraph tags should appear only when you have a need to describe content whose structure is an actual paragraph, not a heading or a list.
Lists
Lists are an extremely useful structural element in XHTML. In addition to helping readers quickly read through content, lists are also useful for marking up site features such as navigation and menus, and even for postal addresses and contact information. There are three types of lists in XHTML: ordered (<ol>), unordered (<ul>), and denition (<dl>) lists. Individual items in ordered and unordered lists are marked up with list item tags (<li>):
<li>Red</li> <li>Yellow</li> <li>Blue</li>
194
A good approach to marking up lists is to begin with the list items rst. Then, determine whether there is any specic order to the items: for example, if they are steps in a process, or an enumerated list of things, they should be grouped using the <ol> (ordered list) tag. If the items are more or less in random order or if their order does not matter, as with the primary colors, group the list items with the <ul> (unordered list) tag:
<ul> <li>Red</li> <li>Yellow</li> <li>Blue</li> </ul>
Because the RPK loads the reset.css le in the XHTML, unordered and ordered lists appear without bullets or numbers, so you must specify them directly using the list-style-type: property on the individual items within the list, as shown in Figure 16.3. Consult
Figure 16.3. This sample style guide shows bullets on unordered lists and decimal numbers and uppercase letters on ordered lists.
TEXT CONTENT
195
your favorite CSS reference to learn about the many different types of bullets and numbers that can be applied to lists.
Nested Lists
Lists can also be nested in XHTML, meaning that individual list items can contain their own sublists (not unlike an outline for a term paper). But nested lists must be structured in a particular way. Nested lists are, in XHTML, considered structurally to be a part of a parent list item. Taking the primary color example, we could nest lists with synonyms for each color:
<ul> <li>Red <ul> <li>Crimson</li> <li>Scarlet</li> </ul> </li> <li>Yellow <ul> <li>Lemon</li> <li>Gold</li> </ul> </li> <li>Blue <ul> <li>Navy</li> <li>Cobalt</li> </ul> </li> </ul>
Notice that on Red, the list item opens, the word Red appears and then a nested unordered list opens, with two list items of its own: Crimson and Scarlet. Then, that unordered list closes, and nally the list item tag that opened before Red closes. As Figure 16.4 shows, you can create additional styles for nested lists, including when ordered lists are nested inside of unordered lists and vice versa.
196
Figure 16.4. This sample style guide shows a few different styles for nested lists, particularly ordered and unordered lists nested inside ordered lists.
TEXT CONTENT
197
Anchor Tags
The anchor tag, <a>, is behind the Webs signature feature: the hyperlink. The anchor tag is used to turn phrases of text into links that can be activated to take a user to another page on your Web site or any other place on the Web. The anchor tag has one requiredand very importantattribute: href, or hypertext reference. The value of href is the address of the Web site or Web page that you want your text to link to. For example,
<p> Read the news at <a href="http://news.google.com">the Google News portal</a>. </p>
will create a hyperlink out of the Google News portal that can be clicked on or otherwise activated by a user. Whenever you are linking to a Web site other than your own, you must include the http:// prex to the full URL. However, when you link to pages in your own site, you need not include the full URL, but merely the path to the le. The path is everything that comes after the domain name; so, for example, if your domain is http://example.com/, the path is everything that comes after .com. If you have a home page at http://example.com/ index.htm and your resume is at http://example.com/resume .htm, you can link to your resume from the home page in one of two ways. The rst is to use a relative link:
<p>View my <a href="resume.htm">resume</a>.</p>
198
The difference? A relative link uses the linking document as its starting point; a root-relative link uses the site root as its starting point; Chapter 20 will examine different kinds of links in greater depth. But other than on your site title (see Chapter 14), avoid using the full URL (also known as an absolute link, e.g., http://example .com/resume.htm) when linking to Web pages that are part of your own site.
Figure 16.5. This sample style guide uses fairly common styles for phrase elements.
TEXT CONTENT
199
By default, the <cite> tag will appear in italic text; but as with <strong>, <em>, and any other tag, its display is ultimately dictated by CSS, not XHTML. The screen.css le in the RPK establishes the typical styles for strong, emphasis, and cite, but you can change them to appear however you wish. Figure 16.5 shows a sample style guides visual design of phrase tags.
INHERITED STYLES
Cascading Style Sheets enable certain styles to be inherited. One basic example of this is using the <body> tag as a selector to set the base fonts and font sizes for your entire page, for example:
body { font-family: Arial, sans-serif; font-size: small; }
Figure 16.6 shows all of the text rendering in Arial, except in the header (which was styled more specically in Chapter 14). Inheritance
Figure 16.6. Setting the Arial font on the body tag causes all of the text on the page to appear in Arialexcept the tagline in the header, which has its own style elsewhere in the style sheet.
200
works on other selectors besides the body and can help you keep your styles short and lean. Remember that its always better to write as little source as possible. For example, if you wish to have a shared line height on all of the text in the content area on your page (see Figure 16.7), you can set that on div#content:
div#content { line-height: 1.6; }
Not only will that keep all of your text looking uniform across the content area, but it also makes changing the line height a matter of xing that one line of CSS (as opposed to having to change the line height on every style). If you nd that you want to alter styles that are inherited, perhaps by setting a shorter line height on your supporting content text, the browser rendering your CSS will replace the inherited style with the new, more specic style.
div#supporting-content { line-height: 1.2; }
Figure 16.7. The line height is inherited by all text in the content division.
TEXT CONTENT
201
Figure 16.8. The line height on the supporting content (in the darker area) has been set to be tighter than in the rest of the content division, whose line height would otherwise have been inherited.
With that style applied, all of your supporting content will have 1.2 for its line height, rather than 1.6 (see Figure 16.8).
Figure 16.9 shows that the descendant selector applies (in that case) the text indent only to paragraphs inside of div#content. (Odds are you wouldnt want to indent paragraphs in your header and footer; youd move them with margin or padding instead.) The screen.css le in the RPK has many descendant selectors for the content area already written for you to use.
202
Figure 16.9. Using the descendant selector, paragraphs in the content area are indentedin this case, a paragraph showcasing phrase tags as we saw in Figure 16.4but the paragraph marking site credits in the footer is not indented.
SPECIAL STYLES
You can go a long way marking up blocks of content with headings, paragraphs, and lists. But sometimes, you will have unique pieces of content that should be treated differently from an ordinary heading, paragraph, or list.
Block Quotes
The <blockquote> tag is an example of adding a bit of structure to paragraphs or long stretches of material quoted from another source. For example,
<p>The United States Constitution opens with:</p> <blockquote> <p>We the People of the United States, in Order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defence, promote the general
TEXT CONTENT
203
Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for the United States of America.</p> </blockquote>
The <blockquote> tag requires that some other block-level tag appear inside of it (headings, paragraphs, or lists). Using CSS, you can style blocks of quoted material:
blockquote { border: 1px dotted black; /*Dotted border*/ padding: 20px; /*Padding adds space between the text and border*/ }
If you have reason to style a paragraph within a block quote differently from your other paragraphs, the descendant selector again comes in handy; simply refer to blockquote p in your CSS.
Classes
As we have seen in earlier chapters, XHTML allows you to write a class (or even multiple classes) on any tag. This structural exibility is useful for marking up page content, because it allows you to specify additional, unique structural features for your content that can be styled using CSS. A class can be called anything you like (though review the naming rules covered in Chapter 9), but the more structurally you name a class, the better. Suppose you wanted pull quotes, which are usually bits of text pulled from your own writing, to appear on text-heavy pages to add visual interest. You might want to style those paragraphs as a big box, but <p class="big-box"> may not accurately describe future designs (or the page as it appears when printed). Opting for <p class="pullquote"> is the better, more sustainable choice. CSS can make it as big and boxy as youd like (see the rendering of both block quotes and pull quotes in Figure 16.10):
p.pullquote { font-size: x-large;
204
NEXT STEPS
Marking up text content is just a matter of being honest: if something is a paragraph, mark it as a paragraph; if its a list, mark it as a list. Thinking about the general types of content on your site will help you to develop your own style guide, which can help you keep your markup consistenteven when you collaborate with others. Once you have some content together and your branding and navigation drafted, you can start to position all of the elements of your site to create the layout for the whole page, which is what the next chapter will cover.
CHAP TE R
17
Page Layout
Put together your pages branding, navigation, and content and you have your whole page. And while so far those elements have been discussed mostly in isolation, an appealing page layout must arrange all of the page elements in harmony. This chapter looks at building page layouts in CSS over well-structured XHTML.
206
Figure 17.1. Adding illustrative background colors to each major division of the document reveals that browsers display blocks to the full width of the screen and in source order.
by default. The second step is to move those elements into place, using CSS positioning, before finally moving other elements out of the way of positioned ones in order to create the illusion of a page layout. And that is really what CSS page layout is: an illusion of columns created by moving some things, and moving other things out of their way.
PAGE LAYOUT
207
208
one part of your site that comprises an overview of your portfolio, which links to individual projects. You can even add unique classes such as class="home" or class="overview", or even class="portfolio-overview" on the <body> tag to help you make specic home- and overview-page adjustments in your CSS later. (See Chapter 20 for help making these kinds of architectural choices for your own site.)
PAGE LAYOUT
209
GRID SYSTEMS
Do a Google search for Web design grid system and you will nd links to the work of many different Web designers who have released their own grid system that others may use. One of my favorite grid systems is Nathan Smiths 960 Grid System, which includes templates for 12- and 16-column grids in the formats of a number of different image editors. It also includes a PDF file for printing out ready-made grid pages to sketch on. As Smith, the 960 Grid System creator, notes: All modern monitors support at least 1024 768 pixel resolution. 960 is divisible by 2, 3, 4, 5, 6, 8, 10, 12, 15, 16, 20, 24, 30, 32, 40, 48, 60, 64, 80, 96, 120, 160, 192, 240, 320 and 480. This makes it a highly exible base number to work with.* Although the 960 Grid System and others like it include XHTML and CSS, they are usually not structurally meaningful the way the RPK is. So try working with some of the sketch sheets and column layouts, but stick to writing your own XHTML and CSS.
*Nathan Smith, 960 Grid System, http://960.gs
Even if you decide to try a simple two-column layout consisting of a 475-pixel-wide area for your content, and a 200-pixel-wide area for your navigation, separated by 25 pixels of space (as in this chapters example), a column structure will help guide you in your image editor mockupparticularly if you opt to enhance your pages with background images to give it a unique look and feel. Figure 17.3 shows an image-editor mockup of the page for this chapter; different areas were sliced from it and saved as separate image les to create the background images in the actual page. Note that the 700-pixel width of the design for this chapter was chosen only because it would work well for images in this book; as in Smiths 960 Grid System (see Grid Systems sidebar), its common to build fixed-width pages that are closer to 1000 pixels across.
210
Figure 17.3. Another image-editor mockup, with images that can be used for the actual design.
CSS POSITIONING
CSS includes the position property, which is often used in conjunction with properties for dimensions (especially widths) and left-, right-, top-, and bottom-offsets to produce all kinds of page layouts from the same XHTML structure. By default, block elements are positioned by the browser statically (position: static;). Two other position values, relative and absolute, are what provide designers the ability to create compelling page designs. When you need to position something far away from where it appears by default, such as the navigation in this chapters examples, position it absolutely. Absolute positioning removes the element from the document owmeaning that the rest of the pages content behaves as though, for example, the navigation is simply gone (see Figure 17.4). To determine what needs to be positioned absolutely, compare where it appears in the normal ow of things (as in Figure 17.1) with where it
PAGE LAYOUT
211
Figure 17.4. The navigation positioned absolutely, and over the content, which must be moved out of the way.
needs to appear (as in the sketches in Figures 17.2 and 17.3). Because this chapters example header is 85 pixels tall, and the design species a space of 10 pixels between the header and the navigation (and content), we write a style like:
ul#navigation { width: 200px; /*200px wide navigation area*/ position: absolute; /*Pull from ow to position*/ left: 0px; /*Keep with left edge of design*/ top: 95px; /*Appear 10px below 85px-high header*/ }
At this point, though, the page is a mess; the navigation and the content appear layered over the top of one another. So the next task is to move other elements out of the navigations way. In Figure 17.5, some left margin on the content area is all that it takes. This margin will also be the only sizing on the content area (that is, no width will
Figure 17.5. With the content pushed out of the way, a two-column layout begins to develop.
Figure 17.6. To create a layout with right-hand navigation is just a matter of a few CSS adjustments.
PAGE LAYOUT
213
The great thing about CSS-based layouts is that they are easily revised. Figure 17.6 shows roughly the same layout as Figure 17.5, but with the navigation on the right rather than the left (and with the content moved off to the right).
Figure 17.7. Centering the page works for all of the nonpositioned elements; the navigation, which is positioned, is stuck on the left, though.
Figure 17.8. The navigation positioned absolutely, but with the container division as its positioning context.
PAGE LAYOUT
215
That way, any changes to the content areas design (particularly its width and distance from the top of the page) would be reected on the supporting content as well; see Figure 17.10. A corrective measure to the supporting content spilling over the footer would be to add more text or media content to the content area. But assuming some pages might need to be short, a designer could
Figure 17.9. Supporting content positioned absolutely; its positioning context should be the content area, rather than the page.
216
Figure 17.10. Supporting content positioned absolutely, but with the content area as its positioning context. Note that the supporting content now spills over the footer.
add a minimum height of 500 pixels to the main content area in this design:
div#main { padding-right: 210px; /*Move content out of the way of supporting, but use padding to keep background color*/ min-height: 500px; /*The main content area should be at least 500 pixels tall*/ }
Figure 17.11 shows the page with the spill-over problem corrected. If there is more than 500 pixels worth of content, the area will automatically expand.
PAGE LAYOUT
217
Figure 17.11. A minimum height on the main content area keeps supporting content from spilling over the footer. Additional content in the main area would have the same effect.
CONDITIONAL COMMENTS
Internet Explorer has a feature, known as conditional comments, that enables you to target XHTML markup to particular versions of IE. If, for example, you need to load a style sheet that corrects some of the idiosyncrasies of IE, conditional comments enable IE to load it; other browsers will see the content as just another XHTML comment. The form of conditional comments looks something like: <!--[if IE]> <link rel="stylesheet" type="text/css" href="screen-ie.css" /> <![endif]--> Visit QuirksMode.org* for additional information on targeting IE using conditional comments.
*QuirksMode.org, Conditional Comments, http://www.quirksmode.org/css/condcom.html
218
Note that because of a problem with min-height in Internet Explorer (IE) prior to version 8,1 you would have to add div#main { height: 500px; } to an IE-only style sheet loaded via conditional comments (the RPK details their use in its screen-ie.css le; see also the Conditional Comments sidebar). IE expands the value specied for height to t longer content, but other browsers, such as Firefox, cut the content off. But that is an acceptable workaround for IEs inability to understand the min-height property.
Figure 17.12. Positioned page with the branding and navigation styles from previous chapters.
PAGE LAYOUT
219
use of gradients, or areas of color that shift from one color to another, is just one means for bringing one area (such as the header) into a polished-looking relationship with another area (such as the content); Figure 17.13 shows the background image that will tile horizontally on the example design in this chapter. Remember that, by default, background images tile horizontally and vertically; to limit an image tiling on the horizontal axis only, be sure to include background-repeat: repeat-x; in your CSS style declarations that use tiled images (to tile vertically, use the repeat-y value). This one background image addition helps pull the design together, as in Figure 17.14.
Figure 17.13. A background image to tile on the body to help pull the design together. (The space around the image is due to how Firefox displays images directly.)
Figure 17.14. The page design with the background image from Figure 17.13 appears less boxy and more complete.
Figure 17.15. A revised layout on the content area, plus a gradient on the content area itself and a darker background color on the supporting content, further improve the page.
PAGE LAYOUT
221
That is a strength of CSS-based design: its possible to experiment with these kinds of revisions without ever touching the XHTML of a page. Tools like Chris Pedericks Web Developer Add-on for Firefox also let you experiment with the design right in your browser window. The footer also looks unnished still; like the header before the addition of the background image on the body, it still looks boxy in Figure 17.16. Remember that there can only be one background image loaded per element in CSS 2; while one has been added to the <body> tag, the <html> tag has none. So heres a bit of CSS trickery to get the same effect from the header and body to work on the footer. First, position the footer absolutely:
div#footer { position: absolute; }
All this does is pull the footer out of the document ow, and in this case, cause the <body> area to behave as though the footer no longer exists. Because of that, the footer now appears over the <html> area of the page. Next, we can add a background imageactually the same background image as the original footerto the html selector in CSS, and
222
have the image positioned at the bottom of the <html> element and repeated on the horizontal, lling the entire page width just like we did for the header (see Figure 17.17). (Once thats been done, remove the background image from the div#footer style declaration.) To make sure the image on html displays on longer pages, its necessary to put some padding on its bottom. The complete style looks like:
html { background-image: url('gfx/footerbackground.png'); background-repeat: repeat-x; /*Tile horizontally*/ background-position: left bottom; /*Show image at bottom of html element*/ padding-bottom: 110px; /*Make room for the footer, and ensure that the html area always displays, even on longer pages*/ }
Figure 17.17. The footer positioned absolutely puts it over the top of the tiled image on the html area.
PAGE LAYOUT
223
Chapter 19 will look at how DOM scripting can be used to alter your design for larger screens.
Figure 17.18. The page looks incomplete because of the white area at the bottom.
224
Figure 17.19. A simple background color x makes the page look more complete, even on large screens.
NEXT STEPS
Using CSS to position elements into a layout is a matter of creating the illusion of columns and boxes. Remember, also, when you work with background images that they sometimes work better on elements other than the element youre actually trying to style, as with the header and footer examples in this chapter. You can nd additional positioning techniques and solutions at the books companion Web site, http:// sustainablewebdesign.com/book/. The next chapter looks at adding images, video, and other media to your pages. But expect to return to your page layout often to make adjustments, particularly as you work to include media like images and video that might need a wider area than your layout accounts for.
NOTE
1. Microsoft Developer Network, CSS Compatibility and Internet Explorer, http://msdn.microsoft.com/en-us/library/cc351024(VS.85).aspx
CHAP TE R
18
Multimedia Content
Chapter 3 provided an overview of gathering and preparing multimedia content, including images, audio, and video. This chapter looks at how to display those media elements and integrate them with the design of your page. Particularly for audio and video, there are many different ways to load media elements on your page; this chapter will suggest only the most accessible and sustainable methods for doing so. But because the precise details of those methods change frequently and are a little too complex to go into here in the book, they are available at the books companion Web site, http://sustainablewebdesign.com/book/. The Rapid Prototyping Kit (RPK) includes a media folder with subfolders for images, audio, and video, as well as for Flash movies and Portable Document Files (PDFs). If you decide to host media content on your own server (versus, for example, using YouTube for video hosting, as this chapter recommends), take advantage of the RPKs folders or a structure like them to keep your media content organized and manageable.
CONTENT IMAGES
All content imagesthat is, all images that appear on your pages when you mean, Have a look at this!should be loaded in the XHTML image tag, <img />. In addition to the <img /> tag being self-closing, there are two important attributes that it must include, src and alt. src: the path to and name of your image le; remember that Web-friendly formats include JPEG les (.jpg, sometimes
226
.jpeg), PNG les (.png), and GIF les (.gif, though usually .png is preferable to .gif). Never try and load TIFF les, or the native les from your image editor (e.g., the .psd les
from Adobe Photoshop). alt: the short alternate text for your image; I prefer to include the text A photo of . . . , or An illustration of . . . , or even A pie graph showing . . . to describe the nature of the image, as well as a few words to describe its content. Web accessibility guidelines suggest that alt text be less than 100 characters, so do keep it brief. Also, it is good practice to include descriptive text somewhere on your page, such as in captions, to clarify the purpose of your images. Markup such as:
<p class="caption"> <span class="access-label">Photo caption: </span>We took this photograph of the Thomas Jefferson memorial during our visit to Washington, D.C. in November of 2010. </p>
MULTIMEDIA CONTENT
227
and accessible CSS for hiding the access label, such as:
.access-label { display: block; /*Display as a block for positioning*/ position: absolute; /*Pull from document ow*/ left: -10000px; /*Move way left of the screen*/ }
can provide additional image descriptions for all users, while hiding (if youd like) the obvious Photo caption label that would be made clearer in your design. The <img /> tag should also include height and width attributes for your images. The values are in pixels, but you do not put the pixel unit in the value. For example, a 200-pixel-wide by 300-pixel-tall image would be specied with width="200" height="300". While height and width attributes are not required, they tell the Web browser to save the space for your images, even before the image is done loading. That can keep your page content from moving around as the images load. Note that you should never resize images with the height and width attributes; do that with your image editors resize or resample function instead. The height and width attributes on your <img /> tags should always match the actual pixel dimensions of the images that they load.
228
HOW TO DESIGN AND WRITE WEB PAGES TODAY <!--Note the space before </span>:--> <p class="caption><span class="access-label"> Photo caption: </span> Image description....
</p> </div>
A little bit of CSS can turn that chunk of markup into a design that complements the photograph and its caption. This example (see Figure 18.1) uses the CSS oat: property to enable caption text to appear alongside and, if the text is long enough, wrap around the image:
div.photograph { background: #333; /*Photos often show up well against darker backgrounds.*/ color: #FFF; /*White text*/ width: 678px; /*Allow for padding and border to total 700px*/ padding: 10px; /*Add a bit of padding*/ } div.photograph img { border: 1px solid black; /*Give denition to lighter edges of photos*/ oat: left; /*Float image to allow text to appear alongside of it*/; margin-right: 10px; /*Keep text away from the image*/ margin-bottom: 10px; /*Also away from the bottom, should the text wrap around.*/ } div.photograph p.caption { font-size: medium; font-weight: bold; }
As with video, images and their presentation elements (a containing division, a caption) must be sized to work with page layout; this particular
MULTIMEDIA CONTENT
229
Figure 18.1. Even minor design enhancements, such as background colors and borders, can improve the presentation of photographs and other media especially if they are used consistently.
example image presentation would require at least a 700-pixel-wide content area. For this reason, work with your images as you develop your page design (see Chapter 17) until you have reached a design and an element-sizing scheme that are in harmony with each other. Images should be large enough to be worth loading and looking atwhile text content in the same area should not be so wide as to be difcult to read. Additionally, it is essential to provide accessible, alternative content on all forms of media, usually in the form of descriptive text but also, in the case of sound and video, transcripts of any narration or dialogue. There are examples of embedding accessible content in the <object> tag (for audio and video, covered next) at this books companion Web site, http://sustainablewebdesign.com/book/.
SOUND
Perhaps more than any other media element, sound must be treated with care if youre not going to drive your audience away with it. For
230
that reason, here is a list of the Three Deadly Sins of misusing sound on the Web: Deadly Sin #1: Sound that plays automatically when someone loads a page. People view Web sites at work, in their ofces, or other places where sound would be embarrassing or unwelcome if it started playing unannounced. Other people prefer to have music playing on their computers while browsing the Web. If sound starts automatically, it creates either embarrassment or an unnerving eld of sonic chaosintroducing the potential for people to justiably hate your site. Deadly Sin #2: Sound that cannot be stopped once it begins playing. If the only way to stop sound on a Web site is to close it or go to another site, that is exactly what site visitors will do. And they will be very wary of listening to any sound on your site in the future, should they ever come back. Its also best to provide some mechanism to pause sound, rather than just stop it, in case someone needs to step away from the computer but would want to pick up where the sound left off. Deadly Sin #3: Sound that is recorded at low levels. Sound that is recorded at low levels (that is, sound that is very quiet relative to other sounds, including music and system sounds) will force visitors to turn up their speakers as high as they can. Such an accommodating move can just about send people out of their minds with fright when music or operating-system soundslike a new email alertplay at their higher levels. Pretty self-explanatory; computers will play other sounds besides yours, and with the audio cranked, poor old Uncle Eds ticker doesnt stand a chance if he receives a new email or logs off his computer. Refer to the audio section in Chapter 3 and this books companion Web site at http://sustainablewebdesign.com/book/ to learn more about ensuring proper sound levels when you record and edit sound les. There are many different plugins and players for sound (see Audio Players sidebar), but the best players will build unobtrusively over
MULTIMEDIA CONTENT
231
AUDIO PLAYERS
Somewhat remarkably, there is no reliable way to play audio natively in most Web browsers (however, HTML5 will eventually change that; see the books companion Web site at http://sustainablewebdesign.com/book/). But in addition to enabling your users to download your audio for use on their own MP3 players, you can try out a number of audio players for your site that work using ordinary links to audio les. All of these players require the Flash player and JavaScript, but they also leave links to your audio intact, so that JavaScript-less users can still download your audio les and listen to them on their own players: Yahoo! Media Player, http://mediaplayer.yahoo.com/ WordPress Audio Player, http://wpaudioplayer.com/ 1 Bit Audio Player, http://1bit.markwheeler.net/ Even as HTML5 continues to gain in popularity, it will likely be necessary to provide audio players such as those for users of older Web browsers.
links to your audio les. That is, to include sound on your page, just link to the le, for example, <a href="/media/audio/mysound. mp3">. That will, at the very minimum, allow someone to download the sound le and play it on whatever media player the person has available. Going a step further, there are a few good choices for unobtrusive JavaScript-based audio players that use Flash: the Yahoo! Media Player is probably the easiest to add. You only have to link to it from the <head> area of your XHTML pages, and it will detect all of the audio les you link to, put a play button next to them, and add a playlist and customizable player to the bottom of your page.1
232
use Flash to deliver video content. However, new mobile devices are challenging the use of Flash, so it is likely that other methods for delivering videoprobably coupled with HTML5will become more important to learn in the future. Again, refer to this books companion site for the latest information. As with images, youll need to determine the dimensions that you want your videos to appear at; sites like YouTube will give you different options along these lines, but note that there are two different aspect ratios that are common to video. The old ratio is 4:3, which is shared with older television sets; the newer ratio is 16:9, sometimes 16:10, which is the ratio of widescreen televisions. The aspect ratio matters because a 4:3 video run at 640 pixels wide will be 480 pixels tall, whereas a 16:9 video that is 640 pixels wide will appear only 360 pixels tall. That matters if you are adding additional XHTML structure and CSS, including background images, to increase the visual appeal of your videos. You can also, if you have access to the proper software, author your own Flash animations for inclusion in your Web pages. (However, as Chapter 19 shows, you can accomplish animation by using JavaScript and a library such as jQuery, especially for interface elements such as the navigation.) Regardless of whether youre loading Flash-based video or a Flash movie of your own construction, SWFObject is one of the better open-source JavaScript libraries for embedding Flash content in a way that is browser-neutral and standards-compliant. SWFObject is included with the RPK. The SWFObject markup is too involved to show here in the book, but there are excellent tutorials available on, for example, using SWFObject to load YouTube videos.3 I also have provided examples and detailed instructions at this books companion Web site.
NEXT STEPS
This chapter has covered some of the core concepts and challenges of loading media content into your Web pages. The next chapter looks at page performance and interaction enhanced by unobtrusive JavaScript.
MULTIMEDIA CONTENT
233
NOTES
1. Yahoo! Media Player, How to Link, http://yahoomediaplayer.wikia .com/wiki/How_to_link 2. Adobe, Flash Player Version Penetration, http://www.adobe.com/ products/player_census/ashplayer/version_penetration.html 3. Heidi Cool, Embedding YouTube Videos the Standards Compliant WaySFWobject 2.0 [sic], http://www.heidicool.com/blog/2008/04/20/ embedding-youtube-videos-the-standards-compliant-waysfwobject-20/
CHAP TE R
19
236
to animate the margins on a site navigations links in response to the mouse hovering and leaving the links.
JAVASCRIPT LIBRARIES
There are a number of high-quality JavaScript libraries available under permissive open-source licenses. While jQuery (http://jquery.com/) is the library I refer to in this book and in the RPK, there are other libraries out there that you might wish to explore: MooTools: http://mootools.net/ Prototype: http://www.prototypejs.org/ A key benet of using a JavaScript library (sometimes also called a framework) is that it does the heavy lifting for the scripting of your site, leaving you to write leaner, high-level code. Libraries that are updated frequently can also improve the performance of your site over time. Also, you can elect to host your own copy of your library at your site, or you can use a service like the Google Libraries API* and pull in the library that the service hosts. While it is usually benecial to have your own copy of the library while youre doing Web development on your computer (if only because you can work without an Internet connection), using the Google Libraries copy may make your live site load faster if someone has already visited another site that also loads the library. And depending on how you load the script from Google,* they can manage updates to the library for you, too.
*Google Code, Google Libraries API Developers Guide, http://code.google.com/apis/libraries/dev guide.html
237
often have to employ certain tricks to get all browsers to interpret the JavaScript the same way. While writing JavaScript entirely from scratch is a useful skill, for the purposes of this book, we will skip ahead to writing DOM scripts that are built using a JavaScript library called jQuery. Libraries like jQuery simplify DOM scripting because they are developed and tested extensively on many different browsers. That usually makes cross-browser compatibility much easier to achieve in your scripts. Additionally, JavaScript libraries simplify DOM scripting by offering an application programming interface (API) to build your own custom scripts. If you think of a library as being something like a DVD player, the librarys API is like the buttons on a DVD player: you probably dont need to know how, for example, the play or pause buttons on the player workbut you know what they should do when you press them. You also know that buttons only work in certain situations or under certain conditions: if a DVD is stopped, for example, the pause button will not do anything. And just as a DVD player comes with an owners manual that documents its functionality, the jQuery librarys general documentation is at http://docs.jquery.com/ and its API is thoroughly documented at http://api.jquery.com/.
238
HOW TO DESIGN AND WRITE WEB PAGES TODAY { /*Scripts are written here to run once the DOM has been loaded*/ }
);
Those lines translate as, When the document object is ready, do all of the things listed here. Using that event and keeping JavaScript out of your XHTML are the most important factors in keeping your JavaScript unobtrusive. (The examples in the remainder of the chapter must appear inside the ready event.) If JavaScript isnt available in a visitors browser, the script never runs, but the site must still be accessible to the JavaScript-less site visitor. jQuery makes certain DOM scripting functions possible using selectors that are identical, or at least very similar, to CSS. If, for example, we wanted to use DOM scripting to put the text DOM Scripting Is Awesome in the <h1> tag inside of <div id="header">, we could use jQuery and write a line of JavaScript like this, inside the ready event shown in the source above:
/*JavaScript inside the ready event*/ $('div#header h1').html('DOM Scripting Is Awesome');
What that would do in the browser is rst select all matching elements from the document (thanks to the jQuery dollar function, $();). It completes the match using a descendant selector that we know from CSS (div#header h1), which will nd all of the <h1> elements inside of <div id="header">. (However, there should be only one match for <h1> on pages constructed according to the guidance in this book.) The <h1> tags text will then read DOM Scripting Is Awesome, regardless of what text the tag contained before. Provided that that structure appears in your XHTML, the element selected by $('div#header h1') is returned as an object by jQuery and the Web browser. In computer languages, objects have two basic features: methods and properties. Methods are particular things that either object can do or can have done to it: by passing text to the html()method, we can set (rather than just read) the <h1> elements contents. Properties are information about the objectthe example above refers to the html() method; used by itself, that method will
239
read a specic property: the text and any XHTML tags that <h1> contains. Under most circumstances, we would not use DOM scripting to set the text of XHTML elements; you would write the text as youd want it to appear directly in the XHTML itself. In the more practical examples that follow, DOM scripting will be limited to manipulating classes on XHTML elements, which are then styled differently according to rules in the CSS. In one example, we will also preview the animation capabilities of JavaScript by progressively enhancing the link states on site navigation. This may be all a bit much and confusing. But whether or not you are ready to agree that DOM scripting is awesome, the concepts should become clearer in the working examples below.
That line uses the dollar-sign function to select the <body> tag on a page (In a compliant page, there should be only one <body> tag, of course.) The script then uses jQuerys addClass method to add the hasjs class to <body>. Assuming that JavaScript is available and that the users browser understands the DOM (which jQuery checks for automatically), the <body> tag of that document will have the hasjs class once the script has run. (You can check that the class has been added by choosing the View Generated Source menu from the Pederick Web Developer Add-on for Firefox.) Used alone, that line of JavaScript is not very exciting; because its only adding a class, youd not even notice that the script has done anythingunless the class then becomes a hook for any advanced CSS styles that should appear in JavaScript environments. For a purely illustrative example with little practical value, if I wanted all paragraph
240
text to appear in red when JavaScript is available, but black otherwise, my CSS le would include:
p { color: black; } /*Display paragraphs black*/ body.hasjs p { color: red; } /*Display paragraphs as red if JavaScript is available*/
241
We can then refer to that function inside of the ready event by writing:
/*JavaScript inside the ready event*/ rpkwidescreen();
What that function does is determine the width of the window (width), in pixels; if it is greater than 1100 pixels, the script manipulates the DOM to add a widescreen class to <body>. Coupled with the has JavaScript function, widescreen views of the site will have a body tag that looks like <body class="hasjs widescreen"> once the page is loaded and the lines of the script have run. Perhaps the site specied a default layout, using the div#page selector in CSS, that is 700 pixels wide, as in the example from Chapter 17 (see Figure 19.1):
Figure 19.1. The layout as it would appear without JavaScript active (or JavaScript enhancement).
242
Just below that style, one could write a widescreen style, using the widescreen class as a hook:
/*CSS*/ body.widescreen div#page { width: 1000px; }
Depending on how the rest of the page is designed in CSS, that simple addition may be enough to improve the sites appearance. In the case of the example from Chapter 17, the style declaration on the descendant selector with the widescreen hook is indeed all it takes to change the design (see Figure 19.2). There is one problem, however: in its current form, the rpkwidescreen(); function is run only once, when the page is loaded. Suppose someone changes the size of his browser window while looking at the siteeither using the maximize button or dragging the corner of the browser window to make it larger or smaller. Either way, the window size has changedperhaps to a wide screen size, perhaps to
Figure 19.2. Using the widescreen class that a bit of DOM Scripting adds to the body, the layout can be adjusted in the CSS to suit larger screens.
243
a small screen size. To account for changes in the browser window size, an additional line of JavaScript would be necessary:
/*JavaScript inside the ready event*/ rpkwidescreen(); /*Check the window size when the DOM is ready*/ $(window).resize(rpkwidescreen); /*Check again, whenever the window is resized*/
Using another event (resize), the rpkwidescreen(); function will run every time the browser window changes size. Resizes that are greater than 1100 pixels wide will result in the widescreen class being added to <body> (or being left on, if it already was added). If the window is less than 1100 pixels wide, the widescreen class will be removed if it had been added previously. The browser should automatically redraw the layout, if there is a change in size/class, using the appropriate instructions in the CSS.
244
support them for use in CSS. So rather than write a special class for each external link in the XHTML, we could write a bit of DOM scripting that looks for all anchor tags whose href attribute begins with http://, and then add the ext class to each external link the script nds. Because contextual links are probably limited to the main content area (div#content), this script will use the descendant selector coupled with an attribute selector that looks for href values beginning with http://:
/*JavaScript inside the ready event*/ $('div#content a[href^=http://]').addClass('ext');
Adding a style declaration to the CSS could then color external links red by referring to the ext class that DOM scripting adds:
/*CSS*/ a.ext { color: red; }
Users without JavaScript will not experience any difference in your links, so if you think that it is critical for all users to be able to visually distinguish between internal and external links, the manual route of putting class="ext" on your external links in your XHTML source would be the better way to go.
245
In fact, to progressively enhance your pages, you would want to leave that in place, so that JavaScript-less users would see an indication of which link theyre hovering over. But to enhance the hover effect, we can use the hover(); and animate(); methods in jQuery to provide a smooth animation. Rather than the CSS jumping from 30 pixels to 0 pixels of righthand margin in the blink of an eye, we can tell jQuery to make the transition over a period of time, using either keywords such as fast or slow, or a specic time value in milliseconds (one second is equal to 1,000 milliseconds). The DOM scripting for this looks like:
/*JavaScript inside the ready event*/ $('ul#navigation a').hover( function() { $(this).animate( { "margin-right": 0 } , "slow"); }, function() { $(this).animate( { "margin-right": 30 } , "slow"); } );
What those lines accomplish are rst to select all of the anchor tags inside of <ul id="navigation"> and then add a hover event to them. The hover event in jQuery can take two functions: the rst species what happens when a mouse moves over the element and the second species what happens when the mouse moves out and away from the element. The $(this) selector refers to the element selected originally (ul#navigation a), and it takes the animate(); method, which can animate any numerical property in CSS (such as widths, heights, margins, padding, and opacity but notimportantlycolors; youd need to use the jQuery UI library or another plugin to animate colors). With that script in place, anyone mousing over the elements in this navigation who also has JavaScript will see the navigation buttons slowly become wider when they are moused over and slowly shrink
246
FINDING SCRIPTS
You can nd all kinds of freely downloadable JavaScript code on the Web. But be very cautious of using just any old JavaScript, as many use outdated practices. A safer way to search for scripts is to look for ones that run with your JavaScript library of choice. Certain libraries, including jQuery, even host plugin libraries that you can browse.* But be judicious and test any plugins well on multiple browsers; the quality of scripts written by others varies widely.
*jQuery.com, jQuery Plugins, http://plugins.jquery.com/
back to normal when the mouse moves away. Have a look at the working example at http://sustainablewebdesign.com/book/.
NEXT STEPS
This chapter concludes the strategies for success for building individual pages. The next steps are for you to build in the rest of the pages of your site and prepare it for going livetopics that are covered in the next section, Problems and Solutions.
NOTES
1. Jeremy Keith, DOM Scripting: Web Design with JavaScript and the Document Object Model (Berkeley, CA: Friends of Ed/Apress, 2005). 2. jQuery UI, jQuery UI, http://jqueryui.com/
PAR T
IV
CHAP TE R
20
Site Architecture
The architecture of a Web site is the organization of all its pages, and how the pages relate to one another. A good site architecture matters to you as a sites designer, as it helps you to easily locate and edit your pages, and link them to one another. Site architecture is equally important to your sites visitors. A sensible URL structure and a site navigation that reveals the general contents of your site increase the likelihood that users will understand whats on your site, how to nd it, and where they are relative to the rest of your site. To build a manageable Web site involves developing a thoughtful, scalable architecture for its pagesand a Web-like environment to test it in. This chapter looks at some of the choices you will have to make in developing your sites architecture once you have a local Web server running to test it in.
That causes serious problems for root-relative links (described below), which will go all the way back to the hard drive, C:/. The le URL also makes things needlessly confusing when it comes to designing
250
your URLs. And if you are using any PHP (see Chapter 21), you also cannot test it in the simple le view, because running a Web server is required to interpret PHP in your pages. The solution to those problems is to set up a little Web server that runs on your computeror even on a USB drive. One of the easiest ways to set up your own Web server for development and testing is to install XAMPP.1 XAMPP is a distribution of the Apache Web server, as well as MySQL and PHP (which are necessary for running WordPress). Although the word server may bring to mind a gigantic computer, a Web server is actually software, like XAMPP, which can run on your own computer while you work up your sites architecture as well as its design and content. (XAMPP is not designed to host your live site, however.) I have posted on this books companion Web site instructions for setting up XAMPP (see http://sustainablewebdesign .com/book/), but on Windows you basically only need to download XAMPP, unzip it to a USB drive, and click the xampp_start application in the xampp/ folder to have a fully operational local Web server. You can then access your pages from your Web browser using a special URL, http://localhost/, provided that you put your site in XAMPPs root web folder, htdocs, which is inside of the xampp/ folder. (There is an htdocs/ folder that comes with XAMPP; you can just rename it to htdocs-original/, in case you need it later, before creating your own htdocs/ folder or copying the htdocs/ folder from the RPK.) When you go to upload your site (see Chapter 23), your actual domains URLs should function the same when you, for example, click on your links as the http://localhost/ URLs in your XAMPP installation. You can think of localhost as a placeholder for your actual domain name.
SITE ARCHITECTURE
Chapter 5 and the Rapid Prototyping Kit (RPK) offer a folder structure for the different design and media components of your site. But the pages that make up your site require an architecture, too.
SITE ARCHITECTURE
251
There are three types of architectures that are commonly used on Web sites: File-oriented architecture, which places all of the XHTML pages of a site in the root Web folder Folder-oriented architecture, which places related pages into separate folders off of the root Web folder Data-driven architecture, which typically relies on databases and the Web server to mimic le and folder references Each of these types of architectures has its benets and appropriate applications, depending on the size and type of site that uses them.
252
SITE ARCHITECTURE
253
the end of the URL and come upon, for example, an overview page at http://example.com/portfolio/. And that is what is meant by a shallow architecture and navigation: a long URL like http://example.com/portfolio/design/ newsletters/ represents a deep architecture, presumably (or ideally) with overviews or landing pages at each level. Representing those in navigation or promotional links becomes a challengeas does sharing URLs in email and elsewhere. Being selective of materials for a site and coming up with a shallow architecture help prevent a site from becoming needlessly complex. That being said, even for areas of your site that might have only one page, you can still use a shallow folder-style architecture. You might save your resume, for example, as index.htm and place it in a resume folder, resulting in a URL for the resume like http://example.com/ resume/.
254
understanding of URL paths, which instruct the browser to load different resources from your site onto a page (images or other media, as well as CSS and JavaScript les), or to take visitors to different pages.
Absolute Links
Absolute links (sometimes called absolute URLs or absolute paths) include your full domain name and the name of the page/resource. For example, the absolute link to your resume might be http://exam ple.com/resume.htm. Absolute URLs are what people commonly share in email and what must be used to link one Web site to another. However, aside from the absolute link to your Web sites home page in the header area of your pages (see Chapter 14), its usually not a good idea to use absolute links to pages within your own site: not only are they longer, but if you should switch domain names or set up archives of your site at a subdomain, for example, http://archive .example.com/resume.htm, any absolute http://example.com/ URLs in your links will no longer refer to items within the same version of the site.
Relative Links
To make sites more portable, you can use relative links, which are links created relative to the current documents place in the site architecture. In a site with a le-oriented architecture, where all les exist directly in the root Web folder, relative links are very easy to write: to link from any page in the site to, for example, your resume, you would just write <a href="resume.htm">view my resume</a>. But if your portfolio were in one folder and your resume in another (and saved as index.htm), to link to your resume from a page in your
SITE ARCHITECTURE
255
portfolio folder, you would have to write <a href="../resume/"> or <a href="../resume/index.htm">. The ../ tells the server to move up one folder (out of portfolio/ and up to the Web root) and then down into the resume folder. To move up two folders would be ../../, three would be ../../../ and so on. It gets confusing pretty quickly; so let relative links serve as another argument against a deep architecture, and perhaps against relative links themselves.
Root-Relative Links
I prefer to write root-relative links in most situations; root-relative links always begin with a slash (/), representing the root Web folder, and proceed to the full path relative to the root of the site. Rootrelative links will work from anywhere in a site, even if you have a very complex architecture: <a href="/resume/"> can be used anywhere; because it starts from the root, it can always be found provided that resume/ is in the root Web folder. (However, rootrelative links will only work during the development and testing of your site if you use something like XAMPP to run a Web server on your local computer.) There is one case where you cannot write root-relative links beginning with a slash, though. If you are using a Web account like you might get through your school or business and it has a URL structure like http://university.edu/~yourusername/, youd need to prex all of your links with /~yourusername/ to make them rootrelativeotherwise, the root-relative links will point to (nonexistent) les and folders off of university.edu/. And, of course, once you have added /~yourusername/ to your links, they will no longer be portable if you decide to purchase your own domain name. So add the root-relative link issue to the list of reasons why Chapter 5 urged you to buy your own domain name, rather than relying on hosting from your school or employer.
NEXT STEPS
As you begin to build a site architecture and test your pages using XAMPP, you move closer to creating a site that is ready for posting to
256
the open Web. The next two chapters look at PHP and WordPress; if you arent interested in those for the time being, skip ahead to Chapter 23, which talks about transferring your Web site to the server space that youve purchased from your Web host.
NOTE
1. Apache Friends, XAMPP, http://www.apachefriends.org/en/xampp .html
CHAP TE R
21
258
When you purchase Web hosting, youre not just purchasing storage space: youre purchasing access to a Web server, which can do much more than simply transfer les down to a visitors Web browser. The metaphor that I like to use is that Web sites made up of static XHTML pages are sort of like vending machines, whereas dynamic sites are more like fast-food restaurants. If you post an XHTML le to your Web site, and someone accesses it, the page on their machine is identical to the one on your servernot unlike when you see a candy bar in a vending machine, put in your money, and hit the button for the candy bar. Nothing changes about the candy bar when it falls from its little slot and into your hands. Dynamic pages, however, are prepared by the Web server; its a process thats instantaneous, but what lives on your server is not the complete le as it will be seen by visitors, but rather some mix of dynamic and static content. When you go to a burger joint, they dont (I hope) hand you a bun, ketchup, and a wad of raw meat; they take those ingredients, prepare them, and then hand them to you. Take that example to a Web server offering dynamic content: the server can assemble dynamic content from a number of different les before sending what appears to be a complete, static page to your visitors. From the visitors point of view, there is no difference between a dynamic page and a static one: a dynamic page still appears in the browser as XHTML, CSS, and JavaScript. And thats important to remember, and why this book has looked at XHTML, CSS, and JavaScript so closely: no matter what you have going on behind the scenes on your server, you are still offering XHTML, CSS, and JavaScript for users to experience your Web site. PHP, a recursive acronym that stands for PHP Hypertext Preprocessor, is a widely used open-source server-side scripting language.1 PHP is great for building simple dynamic XHTML Web pages. In fact, it is the language that WordPress (see Chapter 22) and many other open-source Web software packages are written in. In this chapter, we will look at some basic uses of PHP that will prepare you to learn how to create and modify your own WordPress templates.
WRITING PHP
By default on most Web servers, any les containing PHP must be named with a .php le extension (though see the Parsing PHP in .htm Files sidebar). To call PHP into action requires using PHP tags; these are not the same as XHTML tags. PHP tags open with <?php and close with ?>, and they allow you to jump in and out of static XHTML. The server will interpret, or parse, the PHP code appearing between the PHP tags. For example, to output the current year, a le might contain:
<p>The current year is <?php echo date('Y'); ?>.</p>
which during the year 2011 would appear in the browsers source view as
<p>The current year is 2011.</p>
Again, from the visitors point of view, the page is nothing but XHTML. Unless there is something wrong with the Web server,
PARSING PHP IN
.HTM
FILES
By default on most Web servers, any les with PHP that you want the server to parse must have a .php extension. If you have a site with lots of .htm or .html pages, but you decide to include PHP in them, you dont have to rename the le extensions from .htm to .php. Different Web hosts require different instructions for parsing PHP in .htm or .html pages, but usually you must edit the .htaccess le in your sites root Web folder so that it contains a line such as: AddHandler application/x-httpd-php .php .htm .html (This line is included in the RPKs .htaccess le; remove the hashes in front of it to use.) Check the specic documentation for your Web host as to what lines you must put into .htaccess for this purpose. This is an example of why Chapter 5 suggested purchasing Web hosting from hosts that enable conguration with .htaccess les; there will be other examples of .htaccess in the chapter on WordPress.
260
visitors will never be able to detect which parts of your pages are static XHTML and which parts are created dynamically by PHP. (As you will see when you begin to work with WordPress templates, you can jump in and out of PHP as many times as youd like. Just be sure to open and close your PHP tags.)
Anatomy of PHP
The majority of basic PHP involves writing or working with functions. Functions are made up of the function name, followed by open and closing parentheses where you would write any information, known as arguments, that the function needs. For example, if we had a function called greet(); and it took the argument of the name of someone to greet, say Tom, we would write greet("Tom");, which might output Hello, Tom!, depending on how the function itself was written. PHP has both built-in functions, like the date(); function above, and mechanisms to write your own functions. We will look at examples of both below. PHP also has what are known as language constructs; they are sort of like functions, but use a different syntaxone that doesnt use parentheses. The most common construct is echo, which outputs any text youd like, as though youd typed it into your Web pages
PHPINFO
PHP has a special built-in function that will give you all sorts of information about your Web server. Simply write this in a blank text le: <?php phpinfo(); ?> and save it as mysiteinfo.php. Pull it up in your Web browser (e.g., at http://localhost/mysiteinfo.php), and youll see all kinds of information about your Web server or XAMPP development environment (see Chapter 20). That page can help you determine what your server has installed and whether it meets the requirements for running software like WordPress. PHPInfo doesnt make for thrilling reading; just know that its there if you have a question about your Web servers environment or conguration.
yourself. (You will sometimes see a practically synonymous construct, print; the differences between the two are subtle, but for me it comes down to laziness: echo is faster to type than print. Its one less character, and I dont have to inconvenience my pinky to type p.) In XHTML, you would type:
<h1>Site Overview</h1>
Escaping
echo relies on quotation marks (single or double) to specify the
contents of a string, which is just a collection of characters, as far as PHP is concerned. However, when writing plain old English prose, its common to use quotation marks and apostrophes. When quotation marks appear inside of a string marked by quotation marks, for example, they need to be escaped with a backslash, \.
<?php echo "I've just read \"The Road Not Taken\" by Robert Frost."; ?>
Escaping the quotation marks just keeps PHP from being confused that the string is ending earlier than you intend. Sometimes, as when you are writing your own functions, you need to insert the contents of a variable into an echo statement. To do this, you need to use concatenation, a very fancy word for the unfancy task of simply joining strings and variables together. In PHP, you concatenate using dots. For example, if a script had a variable called $username
262
(variables in PHP always begin with a dollar sign), it could be output as part of a greeting by writing:
<?php $username = "Tom"; echo "Hello there, " . $username . "! It is good to see you again."; ?>
wherever you want your navigation to appear. That looks a little ugly, but by using the PHP document root variable, your include instructions should transfer easily from your development environment to your live Web site.
264
Then, to actually call the rpk_head(); function on your XHTML page, youd write something like:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-strict.dtd"> <html> <!--The <head> gets loaded in a dynamically in PHP--> <?php include($_SERVER["DOCUMENT_ROOT"] . "/includes/ functions.php"); rpk_head("Overview"); ?> <!--End PHP; resume static XHTML--> <body>
A more complete function might also output the DOCTYPE declaration and any other repeated elements as part of the function rather than in the static XHTML as in the example above; the very basic <head> area here is only intended as a simplified example. You can nd additional functions in the RPK; see http://sus tainablewebdesign.com/book/.
you can pretty much count on echo and include(); to be around well into the future.
NEXT STEPS
This chapter has only scratched the surface of PHP, but it is enough to help you start work with the content in the next chapter on WordPress. WordPress is written in PHP and has many of its own functions available that you can use to build or edit a WordPress template.
NOTES
1. PHP.net, http://php.net/ 2. Ruby Programming Language, http://www.ruby-lang.org/en/
CHAP TE R
22
268
OPEN-SOURCE PROJECTS
WordPress is an example of an open-source software project. A key idea behind open-source software is that its source is available for viewing and, if released with a permissive license, also for modication and extension. In the case of WordPress, not only is the source available, but there is a large community of people who are actively working on the software. That means that WordPress is more reective of the blogging community that uses it, and also that bugs and potential security issues are usually found and xed very quickly. Even as a user of WordPress, you can contribute to the community by reporting problems, contributing to the documentation, or evenif you get good enoughworking on the WordPress source itself. The techniques for WordPress templating in this chapter are a good rst step in that direction. To read more about the open-source movement, visit the Open Source Initiative at http://opensource.org/. You might also want to read Eric Raymonds book The Cathedral and the Bazaar.*
*Eric S. Raymond, The Cathedral and the Bazaar: Musings on Linux and Open Source by an Accidental Revolutionary, revised and expanded ed. (Sebastopol, CA: OReilly Media, 2001).
One word of caution, though: if you opt to run your Web site with WordPress, you need to make a commitment to regularly update your copy of WordPress so that you always have the latest, most secure version. You should also check before you purchase Web hosting that your hosting company regularly updates its PHP, MySQL database, and Apache Web server and that the hosting companys advertised versions meet the current WordPress requirements for PHP, MySQL, and Apache.
269
to that is the wp-cong.php le, which is where it stores information about connecting to your database and some other information about your Web server and Web site (wp-cong.php is set up the rst time that you install WordPress, although you can edit it in your text editor later, if necessary). So when people access blog posts or pages in WordPress, the URLs are actually instructing WordPress to retrieve records from a database. By default, WordPress has a URL scheme that looks like http://ex ample.com/?q=21, where 21 refers to some record in the database. But if your Web host has enabled Apaches mod_rewrite module (most do, but check before you purchase hosting),1 you can set up WordPress to generate pretty URLs, like http://example.com/about/. (See the sidebar PHPInfo in Chapter 21 for determining your Web hosts server conguration.) Understanding that URL scheme requires a bit of a conceptual shift, though. So far, we have seen that a pattern like http://example .com/about/ usually indicates the presence of a folder called about/ in your root Web folder. Not so with WordPress and mod_rewrite, which let you write URLs that are independent of les and folders. You can
Here are some other tips for reading the Codex: Have PHP.net open to consult on the particulars of PHP. Use your browsers Find function (Ctrl or Cmd + F) to wade through long pages. If you are working to x a problem with your site or template, do not ignore posts in the WordPress forums; the odds are that someone has had the same problem or question as you at some point.
270
even congure WordPress to automatically generate URLs according to particular patterns for different types of content, although you still retain the option to edit the URLs on each blog post or page that you create.2
INSTALLING WORDPRESS
WordPress is constantly revised and improved, so in addition to the installation suggestions at http://sustainablewebdesign.com/ book/, be sure to consult WordPresss instructions.3 However, here are some general points to consider when installing WordPress: If you only want to use WordPress for a blog, and not for the rest of your sites pages, consider installing WordPress in a dedicated folder, such as blog/, so that your WordPress blog would be accessed at http://example.com/blog/. If you want to use WordPress to manage your entire site, you can install it in the sites root Web folder. However, I have found that it is much easier to later update WordPress when its stored in its own folder off of the site root, such as wp/. Youll have to move the WordPress .htaccess and index.php le into your site root, but keeping the core WordPress les in their own directory makes updates easier, and keeps your site root folder more tidy. If you set up WordPress so that you can upload images and other media, consider using the media/ folder from the RPK, perhaps with a wp/ subfolder where WordPress can keep your media uploads organized. By default, WordPress stores uploads inside of the wp-content folder, but that can make upgrading WordPress tricky if you want to start with a clean installation on each upgrade (discussed at the end of this chapter). If you allow comments on your blog, be sure to obtain an API Key from Wordpress.com (the hosting site of Wordpress.org),4 which will let you set up the Akismet plugin that comes with WordPress.5 It does an outstanding job of catching spam comments, saving you the headache of ltering literally thousands of spam comments by hand.
271
TEMPLATING WORDPRESS
WordPress has a system for building custom templates. I have also created a starter WordPress template based on the Rapid Prototyping Kit (RPK). It uses the same structural blocks as the XHTML version of the RPK, so the good news is that if you have used the RPK for designing your XHTML pages, building a WordPress template from your design may be very easy: you may not have to touch the PHP templating les at all; simply copy your CSS les into the correct place in the RPK template folder. (The complete details of the RPK WordPress template are at this books companion site, http://sustainablewebde sign.com/book/.)
272
Additionally, there are les that are used to build the header, footer, and sidebar across all templates and display a custom comment form when necessary: header.php includes the head area and header branding. Some of the information, such as the site title and URL, will be pulled from your WordPress database; the rest you can copy from your RPK prototype le. footer.php includes the footer area, which uses essentially the same XHTML markup from the footer area of the RPKs prototype.htm le. sidebar.php includes the navigation and room for any widgets youd like your site to include. comments.php handles the list of blog post comments and the comment form. functions.php handles any miscellaneous custom site functions in PHP that you wish to include (see Chapter 21). As you will discover by working with the les, templating for WordPress is not a whole lot different from working with the regular RPK except that there is PHP intermingled throughout. Its also helpful to enter a few blog posts in WordPress and/or a few pages, and compare their output in the browser (using View > Source) with the template les as they appear in your text editor. You may also nd it useful to open the WordPress Edit Post page to edit an already-published post, so you can see where the items in the WordPress Edit Post interface (the post title, the post body, the date, and so on) appear in the published post as viewed in the browser. Editing and designing the CSS is no different from editing the CSS for static pages (although the RPK WordPress template does include some additional <div> tags for you to work with). Remember that, no matter what system is running on the Web server, the browser still receives XHTML that you can experiment styling using the Pederick Web Developer Add-on or other in-browser development tools. And because the RPK WordPress templates use the same structure as the plain XHTML version, your CSS from a static site built in the RPK should transfer quite easily.
273
UPGRADING WORDPRESS
If you run WordPress or another blog/CMS package to power your Web site, it is essential to keep your site updated with the latest version. Although WordPress has an automated upgrade system, I nd it preferable to upgrade manually so as to retain control over and see rsthand the changes to my WordPress sites. See the next chapter, Going Live, to learn about connecting to your hosting account and uploading les. Assuming you followed the recommendation above of keeping WordPress in its own directory and the suggestions at the books companion site, upgrading WordPress is not too painful of a process. First, you want to go to your administration panel in WordPress and disable all of your plugins. Second, back up your wp-content folder; this is where, among other things, your le uploads may appear (although if you specify an alternate location for the uploads, outside of the WordPress directory, this is not an issue). Pull a copy of wp-content down from your Web site using your FTP or SFTP client for archival purposes (that allows you to restore your WordPress installation, should something go wrong with the upgrade). You should also be sure to download copies of your wp-cong.php le and index.php where you modied the path to WordPress. Third, its important to back up your database. If you have SSH access, you can do this by running
mysqldump -umyusername -pmypassword wpdatabase > wpdatabase.sql
replacing myusername and mypassword with your database username and password (though keep the u and p) and wpdatabase with the name of your WordPress database. If you dont have SSH access, locate the database administration tool provided by your Web host to dump/export your database for backup. Finally, I prefer to delete all of the WordPress les on my server before uploading fresh copies. Using your FTP program, you can delete the remote folders wp-admin and wp-includes, as well as all of the .php les that begin with wp-. You can also delete xmlrpc.php; a new copy will be uploaded with your upgrade.
274
Download a new copy of WordPress to your computer and drag in your custom theme, plugin, and upload folders (if they are not stored outside of the WordPress folder) to their appropriate locations in wpcontent. Copy over your wp-cong.php and index.php les, too. Then, upload the whole set of les to your server.
NEXT STEPS
WordPress enables you to maintain a dynamic, database-driven Web site. But it requires you do regular maintenance and upgrades over time, including uploading copies of the WordPress site to your hosting space. The key details on moving your sitewhether its a collection of static les or a WordPress installationare covered in the next chapter, Going Live.
NOTES
1. Apache HTTP Server Version 2.0, Apache Module mod_rewrite, http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html 2. Wordpress.org, Using Permalinks, http://codex.wordpress.org/Using_ Permalinks 3. Wordpress.org, Installing WordPress, http://codex.wordpress.org/In stalling_WordPress 4. Wordpress.com, API Keys, http://en.wordpress.com/api-keys/ 5. Wordpress.org, Plugins/Akismet, http://codex.wordpress.org/Plugins/ Akismet 6. Wordpress.org, Template Hierarchy, http://codex.wordpress.org/Tem plates_Hierarchy
CHAP TE R
23
Going Live
Once you have designed and tested your site locally using XAMPP (see Chapter 20) and its working to your satisfaction, its time to publish your site to the Web by copying the les from your computer or USB drive to the space provided by your Web host. Assuming that you have been thoughtful in developing your site architecture by keeping everything in your htdocs/ folder, going live should be a relatively painless task of copying the contents of htdocs/ to the root Web folder provided by your host. This chapter offers some checklists to run through before and after you upload your site.
276
on your computer. These links, however, will not work on the open Web, so be sure that you have moved all of your images into a folder inside of your Web root, and that links from your pages point there. For WordPress sites: Make sure that you have specied your actual URL inside of the WordPress administrative interface and that you have also made any necessary changes in wpcong.php to refer to the database that you have set up with your Web host, including the databases name and the username and password to access it. Also, if you have purchased your domain name from someone other than your Web host (as was recommended in Chapter 5), you will need to go to your domain-name registrars Web site and log into the control panel they provide for managing your domain. Once logged in, you will enter your Web hosts nameservers for your domain (nameservers are usually in the form of ns1.example.com and ns2.example. com; additionally, some registrars require each nameservers IP address, which your host should provide for your information). Thats how you ensure that your domain name points to your site at your hosted server space. Google for nameservers and the name of your Web host and specify different nameservers and the name of your domain provider to determine how to do this. Once you have changed the nameservers that your domain uses, it may take some time (around 24 hours) before your domain points to your actual site.
GOING LIVE
277
Finally, you need to check the address you need to upload your les to. Sometimes this is a generic address for your host (such as ftp. webhost.foo), but that passes your les to your account based on your username. Sometimes you get an FTP address in the form of ftp. example.com that uses your own domain name. If youre using SFTP, though, you usually just specify your domain name for the address: example.com. You will need to specify the correct address in your FTP/SFTP client.
278
GOING LIVE
279
WWW, OR NO WWW?
Some Web sites, like http://www.google.com/ force the use of www. in their URL (if you try to go to http://google.com, Googles server will add the www. onto the URL for you). My attitude, shared with the people behind http://no-www.org/ is that www. is superuous for Web sites. Thats why my site forces http://karlstolley.com. Anyone using www. to access the site will be automatically sent to the correct, www-less URL. However, there is an alternate view, expressed by the community at http:// www.yes-www.org/ who urge the use of www. in Web URLs. Whether you use www. or not, or allow users to use both, is up to you; just make sure that, www. or not, people can access your site at either one. Here are some instructions to put in an .htaccess; these are available in the RPK .htaccess le; uncomment the lines to use no-www or www on your Web server (these may cause problems on an XAMPP installation): Force no www: RewriteEngine On RewriteCond %{HTTP _ HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] Force www: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
you will have to set up your domain to use your hosts nameservers as described above. If youve done that already, try your site again in a few hours. Do your images and CSS les load? If you are seeing your XHTML pages, but not your design, you need to rst check that the les were uploaded. This can be as easy as pointing your browser to, for example, http://example.com/css/screen .css and seeing if your CSS les source displays. If it doesnt, go back to your FTP client and upload it again. If the CSS les source does display, you need to check the paths that load it in your XHTML le (see Chapter 20).
280
Are your XHTML pages and CSS les validating? Particularly if youve included validation links in the footer, try them out and make sure that everything is validating. If they fail to validate, make the necessary corrections and re-upload any problem les.
UPDATING FILES
Unless you do a major overhaul of your site, its usually only necessary to upload your entire site once. Thereafter, you only need to upload les that youve made changes to. That should be as easy as nding your computers copy of the le, and uploading it to the proper location on your Web server with your SFTP client. Always keep both a local and a remote version of your site; CD-ROM or other backups are also smart to maintain in the event that both your own computer and your Web server crash. You dont want to lose your work!
NEXT STEPS
Going live sounds a lot more interesting than it actually is! Copying les is pretty yawn-worthythough it should be exciting to see your site at your own URL that you can share with the rest of the world. Youll use these same steps into the future, editing les on your own computer, checking them, and then uploading them before checking them again on the live site. (If changes dont appear after you upload them, try clearing your Web browsers cache.) The nal chapter of the book will help you learn how to develop a picture of whos visiting your site and how you can share your content to increase the reach of your identity across the Web.
CHAP TE R
24
TRACKING VISITORS
You can hang a poster up someplace but not have any idea who, if anyone, has looked at it. The Web is very different in this way. Each time someone accesses a page on your site, most Web servers record certain information about the visit: the page being accessed, the visitors IP address (a unique number that identies each computer on the Internet), the Web browser the visitor used, and the date and time of the visit. In addition to your Web servers logging activity, you can set up third-party servicessuch as Google Analyticsto track visits to your site.1 Before you get too invested in site statistics, though, realize that visit numbers and page views are only one metricand it some ways, the least important metricof the impact your site has on your identity. A well-designed site with few visitors but that helps to land someone a
282
job is much more rhetorically successful than a site that boasts tens of thousands of visitors but has little impact on them. Nevertheless, it does not hurt to have a picture of who is accessing your site, and what they are looking at and even clicking on while they are there.
283
or PDF les may also be counted as pages, though not necessarily). The number of pages accessed, then, is the closest metric to actual pages that are looked at on your site. But its not even that simple: Part of the problem with Webalizer as with most statistics packagesis that it is limited in its ability to distinguish between an actual human being visiting your site and a search engine robot crawling your site to index it. That makes it difcult to know whether you are racking up visits from people or search engines.
284
there are open-source alternatives that you can run yourself, including ClickHeat.4 (Also, shortly before this book went to press, Google Analytics added a beta version of a limited click-tracking service called In-Page Analytics; however, at that time, it only listed click percentages in little balloons next to particular hyperlinked items on a page, as opposed to the heat maps provided by Crazy Egg and ClickHeat.) What these types of services do is offer you a visual map of where on your page users are clicking. Over time, a picture emerges of where in your design users seem most likely to clickyour navigation, contextual links, and other areas. One of the more useful things you can learn through click tracking are elements that arent clickable but that users are clicking on anyway. That kind of information is helpful in improving a design: either make the element (photographs especially seem to draw clicks) clickable, or come up with a design that does not invite clicking on nonclickable elements.
285
visits, can be very helpful to making your site growand help you to reach more of your potential audience. Where are people coming from? Webalizer and Google Analytics both track where your visitors came from; if someone has linked to your site, go check out their page. Why are they referring to your site? You might also notice that users are arriving from Facebook, Twitter, and other social media sites. Are people coming back? Google Analytics offers some very helpful tools to help you track return visits (though these are limited to visits from the same computer; a single public computer at a library may actually represent many different visitors, each of whom came to your site for the rst time). Try and determine whether people are coming back to the same content, or to new contentsuch as blog postsand use that information to reward return visits to your site by regularly posting new material.
SHARING CONTENT
Knowing more about whos visiting your site is interesting and helpful, but the reach of your identity on the Web should be about more than page views on your site itself. Enhancing your online identity is something you can do by making it easy for visitors to share your content. At rst glance, that may seem counterintuitive: people who write Web sites should greedily want as many visits to their own site as possible, right? Not necessarily. Think back to the rst chapter of this book, when you did Google searches on your name. One of the ideas there was to use Google to establish a picture of who you are on the Web. Your site is one part of that, but if you make it easy for others to use your content (and give you credit for the content, and a link back to your site), your reputation extends across the Webeven if visits to your site do not increase measurably (though they certainly might). Once your site is live on the Web, you can start to take advantage of the ability to share content. Part of sharing content is a matter of content licensing, perhaps under Creative Commons licenses, which allow people to repost, and perhaps modify, your content. But the other part of sharing content is publishing it to your site with enhancements that makes it easy to share on social media Web sites.
286
Licensing Content
One way to share content is a legal move: licensing your content under some form of content license. Creative Commons licenses are one option to alert your visitors as to what they can and cannot do with your content.5 The basic idea behind Creative Commons is that you gain more by being more permissive with your content. If you take a great photograph, or write some interesting text, and someone wants to use it, by licensing your content under Creative Commons, you can give people specic guidelines as to how your content may be used. In the words of the Creative Commons Web site, the licenses help you keep your copyright while allowing certain uses of your worka some rights reserved copyright.6 All Creative Commons licenses specify that people republishing or building on your work must give you attribution; on your Web site, you might additionally specify that they need to provide a link to your site. Additional Creative Commons license permissions include the ability to remix or alter your content, and to do so for commercial purposes. There are four basic features of Creative Commons licenses, and you can pick and choose which features accompany how you license your work using the Creative Commons licensing tool:7 Attribution: All Creative Commons licenses require that someone using your work give you credit for your work. You can specify how you would like attribution given to you (e.g., with your name hyperlinked back to your Web site) somewhere on your Web site. Derivative Works: You can license your work so that it can be used only in its original form (no derivatives) or that people can alter, remix, or build upon your work. Share Alike: You can specify that anyone using or building upon your work (if you allow them to make Derivative Works) must, in turn, license that derived work under the same license as your original work. Commercial Use: Finally, you can specify whether your content may be used for commercial purposes, for example, to sell goods and services or to be sold itself.
287
So the most restrictive Creative Commons license would stipulate that nobody is allowed to make derivatives of your work, and that it may not be used for commercial purposes. The most permissive Creative Commons license would allow derivative works and allow your work to be used for commercial purposes. If you have questions about Creative Commons or other licenses, however, you should speak to an attorney.
Someone can then easily post your page to Facebook, or a social bookmarking service like Magnolia (which uses Facebook Share), and the shared or bookmarked item will have exactly the title, description,
288
and thumbnail that you specify. (These metatags are available in the RPK; just uncomment to use them. The RPK WordPress template prepopulates the title and description, though you must add your own thumbnail.) You can even add a Facebook Like button to each of your pages for sharing content directly on Facebook.10 Other sites, such as AddThis,11 provide buttons for your site that enable one-click sharing of your content on a variety of different social media Web sites.
NOTES
1. Google Analytics, http://www.google.com/analytics/ 2. The Webalizer, http://www.mrunix.net/webalizer/ 3. CrazyEgg, http://crazyegg.com/ 4. Labsmeida, ClickHeat, http://www.labsmedia.com/clickheat/index .html 5. Creative Commons, http://creativecommons.org/ 6. Creative Commons, What Is CC?, http://creativecommons.org/about/ what-is-cc 7. Creative Commons, License Your Work, http://creativecommons.org/ choose/ 8. Google Reader, http://www.google.com/reader 9. Facebook Developers, Facebook Share, http://developers.facebook .com/docs/share 10. Facebook Developers, Like Button, http://developers.facebook.com/ docs/reference/plugins/like 11. AddThis, http://www.addthis.com
There are countless books and resources on Web design, but it can be difcult to know which are worth your time to read. Below is a list of my favorites, many of which I consult regularly in my own Web writing and design work. Most are written for advanced audiences, but the techniques and approaches in How to Design and Write Web Pages Today will prepare you to engage with these additional resources.
290
Unmatched Style, http://ww.unmatchedstyle.com/ Another ne CSS gallery that also features audio podcasts and a good blog.
COMMUNITIES
Before posting to any community forums, be sure you familiarize yourself with their posting policiesand that youve done your research (including searching their forums for a same or similar question as yours someone might have posted previously.
CSS Beauty, SkillShare Forum, http://cssbeauty.com/skillshare/ A quiet and generally welcoming community of Web professionals and amateurs. SitePoint, SitePoint Forums, http://cssbeauty.com/skillshare/ A large and active community, covering topics from hardcore development to design basics; do your homework before posting a question. WordPress.org, WordPress > Support Forums, http://wordpress.org/support/ The best community to turn to in all matters for WordPress installation, use, and templating.
291
WEB STANDARDS
Cederholm, Dan. Bulletproof Web Design. 2nd ed. Berkeley, CA: New Riders, 2007. A favorite of beginning and advanced Web designers, this book looks at building sites that work best under a wide range of conditions. Keith, Jeremy. HTML5 for Web Designers. New York: A Book Apart, 2010. A compact but complete introduction to HTML5 that will be immediately accessible for anyone with knowledge of XHTML. Zeldman, Jeffrey. Designing with Web Standards. 3rd ed. Berkeley, CA: New Riders, 2009. The dening, classic book on standards-based Web design.
SITE ARCHITECTURE
Morville, Peter, and Louis Rosenfeld. Information Architecture for the World Wide Web. 3rd ed. Sebastopol, CA: OReilly Media, 2006. A classic work in information architecture and a must-read for creators of large Web sites. Walter, Aaron. Building Findable Websites: Web Standards, SEO, and Beyond. Berkeley, CA: New Riders, 2008. Covers a range of topics in site architecture as related to search engine optimization (SEO) and ndability.
292
CSS DESIGN
Clarke, Andy. Transcending CSS: The Fine Art of Web Design. Berkeley, CA: Peachpit Press/New Riders, 2007. A follow-up, in some respects, to Shea and Holzschlags Zen of CSS Design, this book pushes the envelopes of CSS design and is one of the best for exploring the practices behind CSS positioning. Shea, Dave, and Molly E. Holzschlag. The Zen of CSS Design: Visual Enlightenment for the Web. Berkeley, CA: Peachpit Press/New Riders, 2005. An excellent (if advanced) guide to CSS design, using examples from the CSS Zen Garden.
293
VISUAL DESIGN
Elam, Kimberly. Grid Systems: Principles of Organizing Type. New York: Princeton Architectural Press, 2004. A treatment of grid-based design, specically aimed at typography. Lidwell, William, Kritina Holden, and Jill Butler. Universal Principles of Design. Gloucester, MA: Rockport Publishers, 2003. The title says it all: a treasure of different, essentially universal design principles. Samara, Timothy. Making and Breaking the Grid: A Graphic Design Layout Workshop. Gloucester, MA: Rockport Publishers, 2002. An outstanding treatment of grid-based design in print and digital media. Wilde, Judith, and Richard Wilde. Visual Literacy: A Conceptual Approach to Graphic Problem Solving. New York: Watson-Guptill, 2000. A fun book of different visual design problems, with discussion and principles of visual design.
Glossary
Here are brief denitions of the most frequently used technical and design terms used in the text. Additional terms can be found at the books companion Web site http://sustainablewebdesign.com/ book/.
attribute: In XHTML, attributes provide metadata on tags; common attributes include class and id. attribute-value: In XHTML, values assigned to attributes can be called attribute-values; in <div id="navigation">, navigation is the
attribute-value.
byte: A measurement of le size; usually as kilobytes (about 1,000
bytes), megabytes (about 1,000 kilobytes), and gigabytes (about 1,000 megabytes).
child: The immediate tags nested inside a parent XHTML tag. In <p><strong>Example</strong></p>, strong is a child of p. class: An XHTML attribute for adding additional structure that can be shared among a group of elements. client-side scripting: Scripting languages, such as JavaScript, that run in
guage, which the browser builds over the top of structural XHTML.
296
GLOSSARY
descendant: Any tag nested inside of any other tag, no matter how
element selector).
id: An XHTML attribute for adding additional structure to a unique
an element is positioned with regard to. By default, the positioning context is the browser window, but parent elements that are positioned absolutely or relatively become the positioning context for any descendant elements.
property: In CSS, a property is the visual aspect that a style will change; color, font-family, and width are all examples of properties.
GLOSSARY
297
root Web folder: The folder on a Web host that holds the site les; a le named mypage.htm in the root Web folder can be accessed at http://example.com/mypage.htm. selector: In CSS, a selector is what the CSS style will affect; to change
all list items inside of the navigation list, the selector would be
ul#navigation li. server-side scripting: Scripting languages, such as PHP and Ruby, that
colorize the text of different components of a language (and any textual content) to make source easier to read.
validator: A service for checking XHTML and CSS les against the
Chapter 20).
XHTML, Extensible Hypertext Markup Language: A common, standard
INDEX
197 98. See also Paths About pages, 75, 78, 183 84 Absolute positioning, 117, 164, 210 13, 215, 221. See also Document ow Accessibility: CSS and, 34, 66 68, 113 14, 118; denitions, 55 59; design, 61 68; links for, 126, 159 60, 162 66; universal design and, 59 60; user conditions, 58, 60, 69; XHTML and, 65 66, 92, 125, 226 Activity theory: actions, 71, 73 76; activities, 71, 72 73; breakdowns, 76 77; hierarchy, 71 72; operations, 71, 76 77 Adobe Flash, 20, 24, 30, 34, 47, 61, 86, 225, 231 32 alt attribute, 65, 95, 225 27. See also Attributes (XHTML) Analytics. See Site statistics Apache rewrite module (mod_rewrite), 86, 269, 279 Apache Web server, 52, 86, 250, 252, 268 69, 278 Assistive technologies, 25, 41 42, 58 60, 64 65, 118, 159 Attributes (XHTML): accessibility, 64 66, 226 27; on <html>,
96 97, 147 48; use, 95 96. See also specic attribute names Attribute-values (XHTML), 95, 97, 148, 243 Avidemux, 26 Audacity (audio software), 26 Audience, 7, 26, 56 57, 229 30, 284 85. See also Users Audio content, 25 26, 28, 30, 41, 47, 61, 225; plugins and players, 207, 230 31; three deadly sins, 230 Background images: designing with, 130 31, 167 70, 183, 209, 218 24; loading in CSS, 118 19; versus <img /> tag, 175. See also Image replacement <blockquote> tag, 202 3 Blogging software, 10, 49, 52, 253. See also WordPress Blogs, 7, 10, 16, 72, 83, 162 <body> tag, 97 98, 103 5, 199, 221; structural hooks on, 129, 156 57, 175, 183 84, 189, 208, 239 43 Box model (CSS), 115 17. See also Cascading Style Sheet (CSS) properties: boxes and borders
300
INDEX CMS. See Content management system (CMS) Color: CSS keywords, 114, 116; hexadecimal, 116; references in CSS source, 144; rgb() syntax, 116 Comments in source code, 83 84, 142 45 Conditional comments, 48, 217 18 Contact pages, 75, 78, 180 Content. See Audio content; Images: as content; Text content; Video content content attribute, 97 Content management system (CMS), 86, 253, 267, 275 Content versioning system (CVS), 83, 84 Copyright, 172 73 Creative Commons licensing, 160 61, 172, 173 75, 286 87 CSS. See Cascading Style Sheets (CSS) CSS layouts. See Page layout CSS Zen Garden (Web site), 41, 175 CyberDuck, 45, 277 Design inspiration, 17 Development environment, 43 45, 47 49, 122 23, 260, 262 Digital cameras, 28 29 Digital identity: establishing, 3 10, 285; impact on others, 5, 9; usernames, 5 8 Diigo, 8 10, 17, 76, 97, 147 Disability. See Disabled people Disabled people, 55 59. See also Accessibility <div> tag, 98 100, 101 2, 125, 205, 272 DOCTYPE declaration, 94, 96, 147, 264 Document ow, 117, 164 66, 185, 210 11, 221 Document Object Model, 42, 87, 235 36. See also DOM scripting DOM. See Document Object Model
Branding: features, 75 76, 125, 129 30, 146, 153 54, 159 60, 218; footer, 160, 171 75; header, 156 57, 159 71, 208; repeating, 257 58, 272 Browser. See Web browser Cascading Style Sheets (CSS): accessibility, 66 68; browser defaults, 21, 66, 103, 126; comment syntax, 143; inheritance, 103 5; language references, 103, 113, 119, 195; linking to, 154 55, 217, 257; selector specicity, 109; shared, 86 87, 132, 257; signature, 148; style declarations, 105 12, 183 84; W3C recommendation, 41 42 Cascading Style Sheet (CSS) properties, 42, 105, 113 19; backgrounds and images, 118 19; boxes and borders, 115 17; fonts and text, 113 15; hover, 183 84; layout and positioning, 117 18, 210 18 Cascading Style Sheet (CSS) selectors: complex, 111 12; element, 105 6; ID and class, 106 7; pseudo-class, 112 13, 183 84; relationship, 107 10; specicity, 109; universal, 110 11 Center for Universal Design, 59 Character encoding: metadata, 149 50, 151; text les, 141 Character entities, 151. See also Character encoding; Unicode character set (UTF-8) Chrome (Web browser). See Google Chrome <cite> tag, 198 99 Clark, Joe, 58 Clarke, Andy, 109 class: class-itis, 101 10; naming, 84 85, 95 96, 101; structural use, 100 101, 203 4 ClickHeat, 284 Click tracking, 79, 283 84
INDEX Domain names: choosing, 8; hosting and, 53, 276 77; purchasing, 49 51; URLs and, 250, 254, 278 79 DOM scripting: described, 42, 62, 77, 235 36; detecting JavaScript, 239 40; external links, 243 44; JavaScript libraries and, 88, 236 37; widescreens and, 240 43. See also jQuery Dots per inch (DPI), 29 Dynamic content, 86 87, 253, 257 59 ECMAScript. See JavaScript Ego surng, 3 4 <em> tag, 111, 198 99 Emotional design, 70 Errors: isolating problem code, 44, 138, 145; mismatched character sets, 150; validator, 101, 151, 173, 196 Extensible Hypertext Markup Language (XHTML): comment syntax, 143; global structure, 96 98; purpose, 91 92; rules, 92 96; sustainability, 82; W3C recommendation, 39 41 Extensible Markup Language (XML), 39 41, 92 Facebook, 5, 7 10, 75, 285 88 Favicon, 153 54 File extensions, 45 47, 134 37 File formats, 25, 60 61, 86 Files and folders: consistency, 84 85; essential, 47, 124 25; naming and organization, 45 47, 82; uploading and updating, 277 80 FileZilla, 277 Findability, 69. See also Navigation; Site architecture; Waynding Firefox. See Mozilla Firefox Flash. See Adobe Flash Floats (CSS), 117, 185 88, 228 Fonts: alternatives in CSS, 113 14; available, 13, 16, 114; size units, 114 Frames and framesets, 34 FTP/SFTP, 45 46, 52, 134, 267, 273, 276 80
301
GIMP. See GNU Image Manipulation Program Git, 84 GNU Image Manipulation Program (GIMP), 26 Google Analytics, 281, 283 85 Google Chrome, 14 15, 137 Google Libraries API, 236 Google Web search, 3 4, 9 10, 72, 161. See also Search engine optimization Graceful degradation, 62, 64, 157. See also Progressive enhancement Grids and grid systems, 208 10
<head> tag, 97, 148 50, 151 56 Heading tags, 92, 94, 101, 112, 160, 191 92 Home page, 207 8 <h1> tag, 160 62. See also Heading tags Hover styles. See Cascading Style Sheet (CSS) properties: hover href attribute, 155, 197 98, 243 44. See also <a> tag; <link> tag; Paths .htaccess, 52, 252, 259, 270, 279. See also Apache Web server htdocs/. See Root Web folder HTML entities. See Character entities <html> tag, 96 97, 147 48, 221 24 HTML5, 40, 87, 231, 232 HTTP. See Hypertext Transfer Protocol (HTTP) Human-computer interaction (HCI), 71 Hyperlinks. See <a> tag Hypertext Transfer Protocol (HTTP), 37
302
id (XHTML): CSS signature,
INDEX List tags: <li>, 193 94; nested, 19596; <ol>, 194; <ul>, 19495 localhost, 173, 250, 254, 260, 275. See also XAMPP Web server Lorem ipsum text, 25, 190 Lynx, 14, 21, 24, 52, 64 Mac OS X, 14 15, 26 27, 43 45 media attribute, 87, 155. See also Cascading Style Sheets (CSS): linking to Media content. See Audio content; Video content <meta> tag, 97, 148 50, 151 Metadata: <body> tag and, 156 57; contents of pages, 141, 147 48; <head> tag and, 97, 148 56; sharing, 287 88 Microblogging, 5 9. See also Twitter Microformats, 95, 161 62 Microphones, 28 Microsoft Internet Explorer, 13 15, 38, 48 49, 153 54, 217 18, 243. See also Conditional comments Microsoft Windows, 13 15, 27, 43 45, 49, 123, 137, 139, 249 50, 277 MIME type. See Multipurpose Internet Mail Extension type (MIME type) mod_rewrite. See Apache rewrite module MooTools, 236 Morville, Peter, 73 Mozilla Firefox, 14 15, 21, 47 48, 64, 173, 218 MP3 audio, 30, 230 31 Multimedia content. See Audio content; Images: as content; Video content Multipurpose Internet Mail Extension type (MIME type), 148 49, 154, 155 56 MySQL database, 52, 250, 268 Nameservers, 276 79 Navigation: design, 77, 180 84; horizontal, 184 88;
148; naming, 95 96, 101; structural use, 98 100; in URLs, 162 63 Image replacement, 116, 170 71 Images: accessibility, 60 61; compression and, 29 30; as content, 62, 225 29; CSS design and 28 30, 62; formats, 29; preparation for Web, 29; size and quality, 28 29 <img /> tag, 225 26, 227 29 Index le (index.htm, index .php), 73 74, 252, 278 Information architecture. See Site architecture Inheritance (CSS), 103 5, 110, 114, 199 202 International Organization for Standardization (ISO): 8859-1 standard, 149; 638-1 and 639-2 standards, 147 48 Internet Explorer. See Microsoft Internet Explorer ISO. See International Organization for Standardization (ISO) JavaScript: accessibility, 66 68; <body> tag and, 156 57; disabling, 21, 24, 64; libraries, 236, 246; unobtrusive, 64, 154 56. See also DOM scripting jQuery, 88, 232, 235, 236 37; animation, 244 46; custom functions, 240 41, ready event, 237 39. See also DOM scripting; JavaScript Keith, Jeremy, 235 36 Krug, Steven, 69 70, 77
<li> tag. See List tags: <li>
Line breaks, 138 40, 142 43 Link paths. See Paths <link> tag, 154, 257, 287. See also <a> tag Linux, 14 15, 26, 45, 52, 123, 137, 139, 278
INDEX information-seeking and, 73 76; in-page, 64 65, 125 26, 160, 162 63, 164 66; pop-up menus, 74, 181; structure, 178 80 Netscape, 37 38 Nielsen, Jakob, 70 Norman, Donald, 70 Notepad++, 43 45, 133 34, 137, 139, 141
<ol> tag. See List tags: <ol>
303
Progressive enhancement, 62 64, 157, 239 40, 245. See also Graceful degradation Quirks mode, 48, 94, 147, 217 Rapid prototyping: attitudes toward, 122, 123, 131 32; benets, 121 23; components, 122 23, 129 30 Rapid Prototyping Kit (RPK): contents, 47, 123 29; CSS les, 126 29, 155; JavaScript les, 88, 129, 235, 240 41; WordPress template les, 271 72; XHTML les, 65, 94, 125 26, 147 48, 155, 160, 205 Raymond, Eric, 122, 268 Reading: breaking pages, 21 24; content, 18 19; design, 19; multiple browsers, 14; for performance, 20 21; purpose and context, 16 17; views and, 13 Really Simple Syndication (RSS), 7, 151, 287 Redesign. See Site redesigns Rehabilitation Act of 1973, 58 Relative positioning, 213 16 Reset CSS. See Yahoo! Reset Min CSS le (reset.css) Revision, 79, 81 82, 102, 122, 146, 173, 179, 213, 267, 270, 284 Rhetoric, 7, 10, 55, 57, 68, 281 82 Root tag. See <html> tag Root Web folder, 124, 24952, 25455, 259, 262, 26970, 27578 Rosenfeld, Louis, 73 RPK. See Rapid Prototyping Kit (RPK) RSS. See Really Simple Syndication (RSS) Safari (Web browser), 13 15, 21, 48, 137 Sample rates for audio, 30 <script> tag, 154 56 Search engine optimization, 4, 8 9, 26, 161, 284
1 Bit Audio Player, 231 Open source: libraries and projects, 88, 268; media software, 26; Mozilla Firefox as, 16; Web languages and, 35 36; WordPress and, 267 68 Open Source Initiative, 268 Opera (Web browser), 14 15, 21 OS X. See Mac OS X
<p> tag, 192 93 Page layout: centered designs, 213 14; concept, 205 6; liquid and xed, 240; sketches and mockups, 206 8; wide screens, 240 43 Paths: absolute, 198, 254; relative, 198, 254 55; root-relative, 198, 249, 255 PDF. See Portable Document Format Pederick, Chris, 14, 15. See also Web Developer Add-on for Mozilla Firefox Performance, 235 36 PHP Hypertext Preprocessor, 52, 258 61; custom functions, 263 64; escaping strings, 261 62; include(); function, 262 63; language reference, 264, 269 Portable applications, 44 Portable Document Format (PDF), 27, 47, 61, 86, 225, 283 Positioning. See Cascading Style Sheet (CSS) properties: layout and positioning Postels Law, 60, 64
304
INDEX Tables (XHTML), 34, 117, 205 Tagline, 159 60, 162 63, 166 68, 171 73 Tags (XHTML): nesting, 108, 142, 195; references, 45, 94; self-closing, 94, 155, 225; writing, 45, 91 96. See also specic tag names Text content, 41, 43, 189, 191 99, 204, 207, 229 Text editors, 133 34; features, 43 45; writing in, 26, 86, 133 44. See also Source formatting TextWrangler, 45, 135, 137 <title> tag, 97, 151 53, 161, 263, 287 Top-Right-Bottom-Left (TRBL/trouble) order, 115 16 Twitter, 5 10, 26, 35, 65, 75, 285 type attribute, 154 56. See also Multipurpose Internet Mail Extension type
<ul> tag. See List tags: <ul> Unicode character set (UTF-8), 26, 97, 141, 148 51 Uniform Resource Locator (URL): hosting and, 49 50, 173; structuring, 45 46, 85, 100, 135, 161, 197, 249 55; sustainability, 85 86; usernames in, 6, 8, 10; www and, 279 Unique ID (XHTML). See id Universal design, 59 60, 68 URL. See Uniform Resource Locator (URL) Usability: denitions, 56, 69 70; designing for, 70 77; testing, 56, 77 79 Users: activities, 72 73; information-seeking behaviors, 19, 69, 73 76, 77 78, 177 80 UTF-8. See Unicode character set (UTF-8)
Search results: confusing, 4; improving site ranking, 4, 26, 161 Section 508, 58 Secure shell (SSH), 52, 273, 278 Security: challenge questions, 5; FTP/SFTP, 45, 52; online safety, 5; open source and, 268; passwords, 6 Server-side scripting, 257 59. See also PHP Hypertext Preprocessor Server statistics. See Site statistics 7-Zip, 123 Sharing: links, 75; metadata, 285, 287 88. See also Creative Commons licensing Shea, Dave, 170 Shortcut icon. See Favicon Site architecture, 82, 249, 250 51, 275; data-driven, 253, 268 70; le-oriented, 251; folder-oriented, 252 53 Site redesigns, 7, 34, 41, 83 87, 118 Site statistics, 10, 52, 75, 281, 282 85 Smith, Nathan, 209 Sound. See Audio content Source formatting: indentation, 140 42; lines, 138 40; tabs versus spaces, 140, 142 Source literacy, 133 Source order, 117, 125 26. See also Document ow src attribute, 95, 155 56, 225 27. See also <img /> tag; Paths; <script> tag SSH. See Secure shell (SSH) <strong> tag, 198 99 Style guide, 130, 189 90, 204 <style> tag, 154 56 Subheadings. See Heading tags Sustainability: attitudes and, 82; denition, 56, 81 82; design techniques, 83 88, 131 32; libraries and languages, 264 65 SWFObject, 31, 232 Syntax highlighting, 43 45, 137 38
INDEX Validators, 38, 44, 94, 160, 172 73, 196, 280. See also Errors Viddler, 9, 226, 231 Video content, 9, 18 21, 25 26, 28, 30 31, 47, 225, 231 32 Views: different browsers, 15 16; multiple, 134 37; uniqueness and the Web, 13 Vimeo, 226, 231 Waynding, 69, 74 76, 156, 177 78, 183 84 Web Accessibility Initiative (WAI), 57 58 Webalizer, 282 Web browser: browser-neutral design, 16, 126 28; for development, 47 49; rendering engines and, 14 16; View > Source, 35 36, 135, 139, 272; viewport, 144 Web Content Accessibility Guidelines (WCAG), 58 Web Developer Add-on for Mozilla Firefox, 14, 15, 21 24, 43, 48, 64, 173, 221, 239, 272 Web hosting: documentation, 276; features, 52 53; purchasing, 49, 51 53; uploading to, 275 78 Web standards: 33, 3536, 3741, 87 Web Standards Project (WaSP), 37 38 What-you-see-is-what-you-get (WYSIWYG), 27, 82, 122, 133 Widths in CSS. See Box model Wikipedia, 15, 139 Windows (operating system). See Microsoft Windows WinSCP, 45, 277
305
WordPress: Codex, 269, 271; hosting requirements, 268; installation and upgrades, 270, 273 74; templating, 271 72 WordPress Audio Player, 231 Word processors, 27, 34, 35, 133, 138, 150, 192 World Commission on Environment and Development, 81 World Wide Web Consortium (W3C), 33, 37 38, 39 40, 87, 148 Writing: accessibility and, 25; connecting with others, 3 4, 9 10; establishing identity and, 4 9; source comments, 143 45; style, 26, 27 28; Web languages, 89 W3C. See World Wide Web Consortium (W3C) WYSIWYG. See What-you-see-iswhat-you-get (WYSIWYG) XAMPP Web server, 43, 124, 249 50, 254 56, 260, 275, 277, 279 XHTML. See Extensible Hypertext Markup Language XML. See Extensible Markup Language Yahoo! Media Player, 231 Yahoo! Reset Min CSS le (reset.css), 126 28, 194 YouTube, 9, 30 31, 225 26, 231 32 Zeldman, Jeffrey, 39
About the Author KARL STOLLEY earned his doctorate from the Rhetoric and Composition program at Purdue University in West Lafayette, IN, where he was Webmaster of the world-renowned Purdue Online Writing Lab (OWL). As assistant professor of technical communication at the Illinois Institute of Technology in Chicago, IL, he teaches graduate courses on Web design, information architecture, and the rhetoric of technology. He also directs Gewgaws Lab (http://gewga.ws), an opensource design and development research group. His publications have appeared in such journals as IEEE Transactions on Professional Communication, Journal of Business and Technical Communication, and Kairos: A Journal of Rhetoric, Technology, and Pedagogy. He has also served as interface editor for Kairos and led its redesign, which was awarded the Council of Editors of Learned Journals Best Journal Design Award in 2009the rst Web-based journal to receive such a distinction. Stolley maintains a Web presence at http://karlstolley.com/ and is on Twitter @karlstolley.