Build Your Own Website The Right Way Using HTML CSS 2nd Edition Ian Lloyd download
Build Your Own Website The Right Way Using HTML CSS 2nd Edition Ian Lloyd download
https://ebookgate.com/product/build-your-own-website-the-right-
way-using-html-css-2nd-edition-ian-lloyd/
https://ebookgate.com/product/build-your-own-database-driven-
website-using-php-and-mysql-3rd-edition-kevin-yank/
https://ebookgate.com/product/rails-novice-to-ninja-build-your-
own-ruby-on-rails-website-3rd-edition-goodrich/
https://ebookgate.com/product/rails-novice-to-ninja-build-your-
own-ruby-on-rails-website-3rd-edition-glenn-goodrich/
https://ebookgate.com/product/sell-your-own-damn-movie-1st-
edition-lloyd-kaufman/
Head First HTML and CSS 2nd Edition Elisabeth Robson
https://ebookgate.com/product/head-first-html-and-css-2nd-
edition-elisabeth-robson/
https://ebookgate.com/product/consulting-contracting-and-
freelancing-be-your-own-boss-2nd-edition-ian-benjamin/
https://ebookgate.com/product/build-your-own-smart-home-1st-
edition-anthony-velte/
https://ebookgate.com/product/mastering-integrated-html-and-
css-1st-edition-virginia-debolt/
https://ebookgate.com/product/html-xhtml-and-css-bible-3rd-
edition-pfaffenberger-b/
Summary of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
1. Setting Up Shop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2. Your First Web Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3. Adding Some Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4. Shaping Up Using CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
5. Picture This! Using Images on Your Web Site . . . . . . . . . . . . . . . . . . . . . . . 177
6. Tables: Tools for Organizing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
7. Forms: Interacting with Your Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
8. Launching Your Web Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
9. Adding a Blog to Your Web Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
10. Pimp My Site: Cool Stuff You Can Add for Free . . . . . . . . . . . . . . . . . . . . 377
11. Where to Now? What You Could Learn Next . . . . . . . . . . . . . . . . . . . . . . . 407
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
BUILD YOUR OWN
WEB SITE THE
RIGHT WAY USING
HTML & CSS
BY IAN LLOYD
2ND EDITION
iv
Build Your Own Web Site The Right Way Using HTML & CSS
by Ian Lloyd
Notice of Rights
All rights reserved. No part of this book may be reproduced, stored in a retrieval system or transmitted
in any form or by any means, without the prior written permission of the publisher, except in the case
of brief quotations embodied in critical articles or reviews.
Notice of Liability
The author and publisher have made every effort to ensure the accuracy of the information herein.
However, the information contained in this book is sold without warranty, either express or implied.
Neither the authors and SitePoint Pty. Ltd., nor its dealers or distributors will be held liable for any
damages to be caused either directly or indirectly by the instructions contained in this book, or by the
software or hardware products described herein.
Trademark Notice
Rather than indicating every occurrence of a trademarked name as such, this book uses the names only
in an editorial fashion and to the benefit of the trademark owner with no intention of infringement of
the trademark.
48 Cambridge Street
Collingwood VIC Australia 3066
Web: www.sitepoint.com
Email: [email protected]
ISBN 978-0-9804552-7-4
Printed and bound in the United States of America
v
Ian Lloyd is a senior web designer/developer who works full time for a major financial services
organisation in the UK on their various web sites. He is the author or co-author of a number
of web development books, including SitePoint’s Ultimate HTML Reference. He has also
contributed articles to industry-leading sites such as A List Apart, Vitamin and .Net magazine.
Ian has spoken at several high profile web conferences—including South By Southwest
(SXSW) in Austin, Texas and @media in London— on his area of expertise, web accessibility,
and is responsible for the respected online accessibility resource Accessify
(http://accessify.com/).
Ian lives in Swindon, UK, a town that is known only for two things:
■ the famous “magic roundabout”—a mega roundabout that comprises five individual but
joined roundabouts
■ for being that place from the television show The Office (thus making it second in dullness
only to Slough)
That said, Ian does his best to get out of Swindon in his treasured air-cooled VW camper van
(http://vwkombi.com/) whenever the opportunity (or notoriously grim British weather) allows.
Ian is married to Manda, who doesn’t share the Volkswagen fascination to quite the same
level but enjoys the weekend trips it affords. He takes too many photos, most of them of his
dog ‘Fraggle’ (a mischievous Cairn Terrier), and is still waiting on that elusive lottery win
which will allow them all to head off on travels around the world again.
Andrew Tetlaw has been tinkering with web sites as a web developer since 1997. Before that,
he worked as a high school English teacher, an English teacher in Japan, a window cleaner,
a car washer, a kitchen hand, and a furniture salesman. He is dedicated to making the world
a better place through the technical editing of SitePoint books and kits. He is also a busy
father of five, enjoys coffee, and often neglects his blog at http://tetlaw.id.au/.
Julian Carroll has been designing for the Web since 1996. He manages the SitePoint Solutions
(http://www.sitepoint.com.au/) team, and is a keen sampler of wine. Prior to his career as a
web designer, he played bass in a rock 'n' roll band.
vi
About SitePoint
SitePoint specializes in publishing fun, practical and easy-to-understand content for web
professionals. Visit http://www.sitepoint.com/ to access our books, newsletters, articles and
community forums.
For Manda, my “better half”. This
book would not have been
possible without your continued
support. All my love, Lloydi.
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
What is a Browser? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Who Should Read This Book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
What You’ll Learn from This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
How You’ll Learn to Build Your Web Site . . . . . . . . . . . . . . . . . . . . . . . . xxiv
HTML, Markup, CSS… Welcome to Your First Bits of Jargon! . . . . xxiv
Building the Example Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvi
What You Can Expect from the Example Web Site . . . . . . . . . . . . xxvi
What This Book Won’t Tell You . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvi
What’s in This Book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
The Book’s Web Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
The Code Archive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
Updates and Errata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
The SitePoint Forums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxx
The SitePoint Newsletters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxx
Your Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi
Conventions Used in This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii
Windows Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Mac OS X Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Creating a Spot for Your Web Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
Preface
Congratulations on buying this book. Oh, wait a minute—perhaps you haven’t yet.
Perhaps you’ve just picked up the book in your local bookshop, and are trying to
decide whether it’s right for you. Why should this be the book that makes it into
your shopping basket? The answer can be found in the title of the book. It’s all about
getting it right the first time and not learning bad habits—bad habits that you have
to unlearn at a later date—for the purpose of a quick result.
Let’s take a step back for a moment, and look at another skill that many people learn
at some point in their lives: learning to drive. Apologies if that particular experience
is also new to you, but stick with me. For many people, their first driving lessons
can be very confusing; they have to figure out which pedals to press, in what order,
and manage to drive off without hitting anything. Meanwhile, other more experi
enced people just jump into their cars, start the engine, and drive from A to B without
really thinking about what they’re doing. These drivers may have picked up a few
bad habits along the way, but if they learned with a proper driving instructor, the
chances are they were taught properly from the beginning—following a strict set of
rules to ensure they stayed safe.
The driving instructor tells you to check your mirrors diligently, observe speed
limits, and avoid cutting corners (literally as well as metaphorically!). Imagine,
though, if the instructor told you not to worry about the speed limit signs, to put
your foot down because the road is clear, or told you that the one-way sign “wasn’t
all that important at that time of night.” It’d be a miracle if you passed your driving
test, and the chances are that those bad habits would stay with you (so long as you
could manage to keep your license).
I’ve been designing and building web sites for around ten years now, but I can
clearly remember the joy of creating my first site. Admittedly, in hindsight, it was
a pretty nasty-looking web site, but it achieved the goal at the time—I had published
a web site, and I was able to create it with the bare minimum of tools. It gave me
an enormous sense of achievement, and made me want to learn more and create
even better web sites.
xx
At the time, there was a limited amount of books available that seemed to provide
what I wanted, but I lapped up everything I could find, learning some tricks from
books, and gaining other ideas from visiting web sites. But then I discovered that
I’d been doing it all wrong. The books I had learned from had given me what later
turned out to be poor advice; the web sites I’d visited had been built by people
learning from the same sources and hence, making use of similar, bad techniques.
So, what had gone wrong?
In the early days of the web, when people first started properly to embrace the
technology, to publish homepages, and to develop online corporate presences for
their companies, they all realized fairly quickly that the medium was limited. Ne
cessity is the mother of invention, though. So, web developers began to coax tricks
and displays out of their web pages that were never intended by the technologies
they used; the browsers helped them along the way by adding features that offered
even more opportunities for this kind of behavior.
Numerous books have been written on the topics of web design and programming,
as have many free tutorials that you can read on the web. Many of them were written
during those heady years, and were based on what seemed like best practices back
then; however, their authors were constrained by browsers that often rendered the
same well-designed pages in vastly different ways. This meant that the tutorials’
authors needed to resort to abusing various features of those browsers, such as using
data tables to lay out pages. This certainly encouraged many people to build their
first web pages, but it ensured that bad habits were ingrained at an early stage, and
many people are still using these bad practices years later.
Web developers the world over have learned bad habits (myself included) and must
now try to unlearn them all. There’s no longer a need for these practices—they often
produce pages that are inflexible, slow to download, and difficult to maintain—but
like the badly taught driver who insists on flouting the rules because it’s worked
for him so far, many developers find these outdated habits difficult to break.
I saw the light many years ago, and have tried to educate as many people as possible
since. But for the eager beginner, those same old books are still peddling the same
bad old ideas. This just has to stop. And it stops here and now.
You’re not going to learn any bad habits in this book. Not one.
xxi
In this book, you’ll learn the right way to build a web site. If there’s a wrong way
to do things—a way that cuts corners to save time but encourages bad techniques—we
won’t even tell you about it. Not even as a “by the way, you might try this…” You
won’t need to avert your eyes—we’ll take care of that for you!
What is a Browser?
If you use Microsoft Windows XP or Vista, the browser is probably what you know
as the “little blue e on the desktop” (shown in Figure 1), but is commonly called
Internet Explorer. The majority of people don’t stray beyond using this program for
the purposes of viewing web pages—for many, Internet Explorer is the Internet.
Internet Explorer (or IE, as we’ll refer to it from now on) is the most commonly used
browser, largely because Microsoft included it as part of the Windows operating
system as far back as Windows 95. (This was later to come back and haunt Microsoft:
it became the catalyst for a massive anti-trust trial, which ruled that the company
had stifled competition by bundling IE with the operating system to the exclusion
of all others.)
However, there are other browsers that you can use instead of IE. Still riding a wave
of popularity is Firefox,1 an alternative browser with a number of attractive features
that aren’t available in IE (at the time of writing), and handles the features of some
web pages better than IE can. Firefox is also available for Windows, Mac OS X, and
Linux operating systems; IE, however, is only available for Windows operating
systems. The screen shots you’ll see in this book were taken using Firefox on Win
dows XP, unless stated otherwise. Because of the cross-platform nature of Firefox
and the excellent standards support, I recommend that you download a copy of
Firefox for the purposes of working through the exercises in this book.
1
http://www.mozilla.com/firefox/
xxii
Alternatively, you might like to try another browser that supports web standards
(we’ll cover this soon) well. For Windows users, Opera’s web browser2 offers excel
lent standards support and its own unique set of features (it also has a very loyal
following) and, like Firefox, it can be freely downloaded. Mac users can also use
the Opera browser, the Firefox-like Camino3, or simply stick with the Apple browser
that is installed by default, Safari4, which again offers excellent support for web
standards. A selection of Mac browser icons appears in Figure 2.
Finally, there’s one more browser that you may want to try out—or perhaps you’re
already putting it through its paces—and that browser is Chrome,5 courtesy of
Google. As I sit writing and updating this chapter, Chrome is the newest, freshest
browser available; it’s even has that “new browser smell.” Okay, so it’s not quite
the same as a new car smell! But the point is that this browser is literally just days
old as I write, and currently only available for Windows XP/Vista. By the time you
read this, there may also be versions available for Mac OS X and Linux (Google has
promised they’re on the way), and initial reviews of the browser seem very good
too.
Figure 2. There are numerous browsers that you can try for free, as shown by the Mac dock in the image below
Happy with the browser you’re currently using? Well, if you’re a Windows user and
don’t want to try a different browser just yet, you can still use IE—as indeed the
majority of people using the web still do. In fact, you can be sure that everything
you read here will work in all recent browsers, whatever your choice, without any
real hiccups.
2
http://www.opera.com/download/
3
http://caminobrowser.org/
4
http://apple.com/safari/
5
http://www.google.com/chrome/
xxiii
If any of the above descriptions strikes a chord with you, then this is the book to
put in your shopping cart. We’ll ease you in gently, and have you building web
pages like a pro in no time!
There’s no need to worry if you feel the terminology that your 15-year-old nephew
keeps spouting is beyond you when you ask him about building web sites. I’ve as
sumed no prior knowledge of any of these terms, and I’ll be guiding you all the way
through the process of creating a web site from scratch. By the end of this book,
you’ll know how to build the site, obtain some hosting, promote the site, and keep
it running once it’s live.
The best part is this: what you learn in this book, you’ll never have to unlearn.
You’ll be learning how to build sites the right way from the get-go.
Using an example web site, I’ll guide you through the process of developing web
pages from scratch. From these humble beginnings, great things will evolve! By the
end of the book, you’ll be able to create a web site that includes the following fea
tures:
xxiv
■ easy-to-use navigation
■ a professional-looking site header
■ a regularly updated news/events section
■ a Contact Us page
■ tables—the presentation of data in neatly organized grids
■ attractive web page forms
■ a simple image gallery
■ a search engine that covers your site, as well as related sites
■ simple statistics that you can use, for example, to see who’s using your site, how
they found your site, and so on
You’ll also learn how to manage your web site effectively, without it becoming a
chore or too technical. I’ll show you how you can:
■ establish your own dot-com (or dot-net, dot-org, or the like) web address
■ find a place to host your web site
■ upload your files to your web site
■ gain feedback from visitors while avoiding spam emails
HTML
HTML stands for HyperText Markup Language. It’s the primary language that’s
used to create web pages, so you’ll come to know it very well through the course
of this book. We’ll be using XHTML syntax in the example web site, an updated
xxv
Markup
Imagine, if you will, that you’re a newspaper editor. You’ve been passed a news
story, but the text—from the heading through to the conclusion—is all the same
size, and the headings, paragraphs, quotes, and other features of the text are not
clearly indicated. It’s just one big block of text. For starters, you’d probably want
to emphasize the headline, maybe by displaying it in bold or italic text (or in
caps with an exclamation mark if you were working for a tabloid). As an editor,
you’d probably grab a pen and start scribbling annotations on the printout: an
h here to signify a heading, a p here, there, and everywhere to show where
paragraphs start and end, and a q to denote quotations.
This is essentially what markup is—a set of simple tags that suggest the structure
of a document: this section is a heading, paragraph, quote, and so on. We’ll
cover the various tags that HTML uses in detail a little later.
CSS
CSS stands for Cascading Style Sheets. We’ll be using a combination of XHTML
and CSS to create web sites. CSS is a language that lets you control how your
web pages look, but we’ll go over that in more detail later. For now, it’s important
that you know what the abbreviation stands for.
Web Standards
Web Standards advocate best practices for building web sites. Whilst the term
Web Standards may be used to describe a range of philosophies and specifica
6
http://reference.sitepoint.com/html/html-vs-xhtml
xxvi
Each example is complete: nothing’s missing. You’ll see the picture build gradually,
so you won’t be left trying to guess how the example web site arrived at the point
it’s at. The files we’ll use in all the examples are provided in a separate code archive
(described in more detail in a moment).
You can pick up the project at any point, so mistakes you might have made in a
previous chapter’s exercises won’t come back to haunt you!
This book won’t try to force-feed you everything there is to know about creating
web pages; instead, it focuses on the most useful aspects that you’ll find yourself
using over and over again.
■ JavaScript
xxvii
By the time you’ve finished this book and have had a chance to tackle your own
web site, you might want to take the next steps to increasing your site-building
knowledge. I’ll make recommendations where appropriate throughout the book,
and suggest other resources that you might like to check out.
So, this is where the introductory bits end and the process of learning begins—learn
ing how to build web sites the right way. So step this way, ladies and gentlemen …
general. First, we’ll review the full range of border effects that you can apply to
elements such as headings and paragraphs. We’ll experiment with dotted borders,
and big, bold borders, as well as some slightly more subtle effects. In the second
half of the chapter, we’ll learn how it’s possible to use CSS to position the ele
ments of a web page—including blocks of navigation—anywhere on the screen.
Chapter 10: Pimp My Site: Cool Stuff You Can Add for Free
You’ve heard of the MTV reality program Pimp My Ride, right? No? Well, every
week, these guys take an everyday car and transform it—with some well-placed
and carefully executed cosmetic touches—into a real head-turner of a vehicle.
And that’s the aim of this chapter for your web site! You’ll discover that there
are all kinds of tools, plugins, and add-ons that you can build into your web
site to make it even more useful for you and your visitors. Among the tools on
offer we’ll find site search facilities, statistics programs, and online discussion
forums.
The weekly SitePoint Tech Times covers the latest news, product releases, trends,
tips, and techniques for all technical aspects of web development. The long-running
SitePoint Tribune is a weekly digest of the business and moneymaking aspects of
the Web. Whether you’re a freelance developer looking for tips to score that dream
contract, or a marketing major striving to keep abreast of major search engine changes,
this is the newsletter for you. The SitePoint Design View is a monthly compilation
of the best in web design. From new CSS layout methods to subtle Photoshop
techniques, SitePoint’s chief designer shares his years of experience in its pages.
The SitePoint Community Crier is the newsletter of the SitePoint Forums, where
over 150,000 web professionals and enthusiasts keep abreast of all SitePoint com
munity matters. Finally, The SitePoint Market Watch comes out twice a month with
a focus on purchasing and selling web real estate.
7
http://www.sitepoint.com/forums/
xxxi
Your Feedback
If you can’t find your answer through the forums, or you wish to contact me for any
other reason, the best place to write is [email protected]. We have a well-staffed
email support system set up to track your inquiries, and if our support staff are
unable to answer your question, they send it straight to me. Suggestions for improve
ment, as well as any mistakes you may find are especially welcome.
Acknowledgements
While writing a book sometimes seems like a solitary process, the truth is that there
are a lot of people who indirectly guide—or have guided—the hands that type the
words on these pages. None of this would have been possible had I not been pointed
in the direction of influential and persuasive web sites like webmonkey.com8, whose
CSS tutorial first made me see the light, and individuals such as Jeffrey Zeldman,
Molly Holzschlag, and Eric Meyer, whose pioneering work has benefited me (and
many others) greatly. However, if I were to list the names of all the people who have
inspired me in any way, shape, or form in the last few years, this section would end
up looking more like an index! You folks know who you are, keep up the good
work!
I would like to acknowledge the work undertaken by the Web Standards Project (of
which I am also a member, albeit a pretty inactive one for the last couple of years),
and give a little shout-out to my fellow Britpackers—wear those Union Jack pants
with pride, folks!
Thanks to all those at SitePoint who have helped me in the crafting of this book,
particularly to Simon Mackie, my main point of contact and sounding board, and
my expert reviewer for the first edition, Marc Garrett—your comments were always
on target. Thanks to Matthew Magain, Andrew Tetlaw, and Julian Carroll, who tech
edited the book—I hope I didn’t leave you much to correct or find fault with! And
then of course there’s Georgina Laidlaw and Kelly Steele, who ensured that any
peculiarly British turns of phrases were removed, despite my best efforts to sneak
a few in.
8
http://www.webmonkey.com/
xxxii
Finally, thanks to Manda for putting up with me when deadlines loomed and I all
but shut myself off from civilization to have the chapters in on time. Social life? Oh
that! I remember … At those times it seemed like it would never end, but finally
we can both see the fruits of my labor.
Markup Samples
Any markup—be that HTML or CSS—will be displayed using a fixed-width font,
like so:
webpage.html (excerpt)
If the code may be found in the book’s code archive, the name of the file will appear
at the top of the program listing, like this:
example.css
.footer {
background-color: #CCC;
border-top: 1px solid #333;
}
If only part of the file is displayed, this is indicated by the word excerpt:
example.css (excerpt)
If additional code is to be inserted into an existing example, the new code will be
displayed in bold:
xxxiii
.footer {
background-color: #CCC;
border-top: 1px solid #333;
padding: 5px;
}
Also, where existing code is required for context, rather than repeat all the code, a
vertical ellipsis will be displayed:
.footer {
⋮
margin: 5px;
}
Some lines of code are intended to be entered on one line, but we’ve had to wrap
them because of page constraints. A ➥ indicates a line break that exists for formatting
purposes only, and should be ignored:
URL.open("http://www.sitepoint.com/blogs/2007/05/28/user-style-she
➥ets-come-of-age/");
Menus
When you need to select an option from a menu, it’ll be written as File > Save; this
means “select the Save option from the File menu.”
Hey, You!
Tips will give you helpful little pointers.
Ahem, Excuse Me …
Notes are useful asides that are related—but not critical—to the topic at hand.
Think of them as extra tidbits of information.
xxxiv
Watch Out!
Warnings will highlight any gotchas that are likely to trip you up along the way.
1
Chapter
Setting Up Shop
Before you dive in and start to build your web site, we need to take a little time to
get your computer set up and ready for the work that lies ahead. That’s what this
chapter is all about: ensuring that you have all the tools you need installed and are
ready to go.
If you were to look at the hundreds of computing books for sale in your local
bookstore, you could be forgiven for thinking that you’d need to invest in a lot of
different programs to build a web site. However, the reality is that most of the tools
you need are probably sitting there on your computer, tucked away somewhere you
wouldn’t think to look for them. And if ever you don’t have the tool for the job,
there’s almost certain to be one or more free programs available that can handle the
task.
We’ve made the assumption that you already have an Internet connection, most
likely broadband (or similar). Don’t worry if you have a slower connection: it won’t
affect any of the tasks we’ll undertake in this book. It will, however, mean that some
of the suggested downloads or uploads may take longer to complete, but you probably
knew that already.
2 Build Your Own Web Site The Right Way Using HTML & CSS
Planning, Schmanning
At this point, it might be tempting to look at your motives for building a web site.
Do you have a project plan? What objectives do you have for the site?
While you probably have some objectives, and some idea of how long you want
to spend creating your site, we’re going to gloss over the nitty-gritty of project
planning to some extent. This is not to say that project planning isn’t an important
aspect to consider, but we’re going to assume that because you’ve picked up a
book entitled Build Your Own Web Site The Right Way, you probably want to just
get right into the building part.
As this is your first web site and it will be a fairly simple one, we can overlook
some of the more detailed aspects of site planning. Later, once you’ve learned—and
moved beyond—the basics of building a site, you may feel ready to tackle a larger,
more technically challenging site. When that time comes, proper planning will
be a far more important aspect of the job. But now, let’s gear up to build our first,
simple site.
■ The primary—and most basic—tool that you’ll need is a text editor; a program
that allows you to edit plain text files. You’ll use this to write your web pages.
■ Once you’ve written a web page, you can see how it looks in a web
browser—that’s the application you use to view web sites.
■ Finally, when you’re happy with your new web page, you can put it on the
Internet using an FTP client—a utility that allows you to transfer files across the
Internet using the File Transfer Protocol. Using FTP may seem a little complicated
at first, but thankfully you won’t need to do it too often. We’ll discuss FTP clients
in detail in Chapter 8.
You’ve already got most of these programs on your computer, so let’s go and find
them.
Setting Up Shop 3
You can find Notepad in the Start menu: go to Start > All Programs > Accessories.
Shortcut to Notepad
To save yourself navigating to this location each time you want to open Notepad,
create a shortcut on your desktop. With the Start menu open to display Notepad’s
location, hold down the Ctrl key, click and hold down the mouse button, then
drag the Notepad icon to your desktop. When you release the mouse button, a
shortcut to the application will appear on your desktop, as in Figure 1.1.
Notepad is the most basic of applications, as you can see from Figure 1.2.
4 Build Your Own Web Site The Right Way Using HTML & CSS
Unlike Notepad, TextEdit works as a rich text editor by default, which means we
can work with fonts, make text bold and italic, and so on. However, we want to
work with TextEdit as a plain text editor, so you’ll need to adjust some of TextEdit’s
preferences. Start TextEdit, then select TextEdit > Preferences from the menu to bring
up the Preferences screen. Select Plain text within New Document Attributes, then
close the Preferences screen. The next time you create a new file in TextEdit, it will
be a plain text document.
If you are using a slightly older Mac, you may also have a copy of Internet Explorer
installed. Our advice for Internet Explorer for Mac? Send it to Trash. The Mac version
of IE was abandoned by Microsoft many years ago, so it’s considerably outdated
and is rarely supported or used in the wider world; no new Macs come with this
application preinstalled. It also bears no real resemblance to its Windows counter
part, for those more comfortable using IE.
Countless other text editors and web browsers are available for download, and many
of them are free. Obviously, we don’t have time to describe each and every one of
Setting Up Shop 7
them, so I’ve settled on a few options that have worked for me in the past, and which
you might like to download and have at your disposal. And remember, they’re all
free!
Windows Tools
NoteTab
NoteTab’s tabbed interface lets you have many different files open simultaneously
without cluttering up your screen, as Figure 1.6 illustrates. Files that you’ve opened
are remembered even after you close the program and open it again later, which is
very useful when you’re working on a batch of files over many days. You can
download the free NoteTab, or its Light version, from http://www.notetab.com/.
Firefox
As mentioned in the Preface, Firefox is a very popular alternative to Internet Explorer
and, as we proceed through this book, it will be our browser of choice for a number
of reasons. As with NoteTab, Firefox offers a tabbed interface that helps keep your
computer free from window clutter. You can download Firefox from
http://www.mozilla.com/firefox/; the browser is depicted in Figure 1.7.
8 Build Your Own Web Site The Right Way Using HTML & CSS
Mac OS X Tools
It is true that there are fewer free programs available for the Mac operating system
than there are for Windows. However, there are a few programs that you might like
to consider as you move beyond the basics.
TextWrangler
TextWrangler is a free, simple text editor made by BareBones Software. As with
NoteTab for Windows, TextWrangler can tidy up your workspace by allowing sev
eral text files to be open for editing at the same time (the documents are listed in a
pull-out drawer to one side of the interface, rather than in tabs). You can download
TextWrangler, shown in Figure 1.8, from the BareBones Software web site.1
1
http://www.barebones.com/products/textwrangler/
Setting Up Shop 9
Firefox
Firefox is popular not just among Windows users, but also with Mac users, many
of whom prefer to use it instead of Safari (often because of the extra features—known
as add-ons—that can be bolted on to the browser). A web page viewed in Firefox
should display the same regardless of whether the browser is installed on a PC
running Windows XP or Vista, on a Mac running OS X, or on Linux, a free, open
source operating system (generally favored by highly technical people who like to
tinker with their computers a lot). The predictability of Firefox is a welcome change
from the bad old days of endless browser competition, and is one very good reason
why we will mainly use Firefox in the examples included in this book.
Unfortunately, when it comes to image editing software, that old saying, “You get
what you pay for,” applies. A professional image editing program, like Photoshop
or Fireworks, costs hundreds of dollars. While these programs offer some excellent
capabilities, we can’t really recommend that you go out and pay for them unless
you’re sure that they’re right for you. If you already have a copy of one of these, or
a similar image editing program, by all means use it and experiment with it. Programs
10 Build Your Own Web Site The Right Way Using HTML & CSS
like Paint Shop Pro or Photoshop Elements (a cut-down version of Photoshop) are
more reasonably priced. However, for the purposes of this book, we’ll look only at
tools that are free to download and offer enough functionality to give you an idea
of what’s possible.
Keep an eye open for free image editors that are included on disks attached to the
covers of Internet, computing, and design magazines. Software vendors often give
away older versions of their software in the hope that users might be tempted to
upgrade to a new version at a later date. Look out for Paint Shop Pro, or any image
editor that supports layers—a way to construct an image by stacking 2 or more
layers, one on top of the other. While we’ll keep our image editing fairly simple
throughout this book, it’s certainly worth keeping an eye open for free (and full-
featured) image editing software, as these offers will not always be available.
These trial versions are typically available for 30 days’ use; after that time you
can decide whether you want to pay for the full software or stop using the program.
However, those 30 days might just be enough time for you to use the software
while you work through this book.
Adobe Fireworks You can download a trial version of Fireworks from the
Adobe web site.5
Paint Shop Pro Paint Shop Pro is available for Windows only. To download
a trial version, visit the Paint Shop Pro site,6 and click the
Free Trial link.
2
http://www.adobe.com/products/photoshop/
3
http://www.adobe.com/products/photoshopelwin/
4
http://www.adobe.com/products/photoshopelmac/
5
http://www.adobe.com/products/fireworks/
6
http://www.corel.com/paintshoppro/
Setting Up Shop 11
Windows Tools
A standard Windows install has not always been blessed with image editing software.
Certainly this was the case with Windows XP (although if you bought the computer
as a bundle with PC, scanner, or digital camera all together, you might be lucky and
find some image editing software included in the deal; scout around in your Start
> All Programs menu to see what you can uncover).
In Windows Vista, the Photo Gallery application has seen some big improvements
over its previous XP incarnation and now includes some basic, but still useful, image
manipulation tools, including cropping, color, and contrast adjustment. The Photo
Gallery application can be found directly in the Start menu.
Picasa
If you’re using Vista, the tools offered in Photo Gallery may do everything that you
need; if you’re using XP, you’ll almost certainly need to use an extra application.
With that in mind, you might like to try out an excellent image management tool
that Google offers for free download. The program is called Picasa, and it’s extremely
Discovering Diverse Content Through
Random Scribd Documents
—Vamos a hacer una cosa—propuso el sainetero amigo de Casares.
—¿Qué?—preguntó Julio.
—Vamos a casa de Villasús. Pura habrá salido del teatro ahora.
Villasús, según le dijeron a Andrés, era un autor dramático que tenía
dos hijas coristas. Este Villasús vivía en la Cuesta de Santo Domingo.
Se dirigieron a la Puerta del Sol; compraron pasteles en la calle del
Carmen esquina a la del Olivo; fueron después a la Cuesta de Santo
Domingo, y se detuvieron delante de una casa grande.
—Aquí no alborotemos—advirtió el sainetero, porque el sereno no
nos abriría.
Abrió el sereno, entraron en un espacioso portal, y Casares y su
amigo, Julio, Andrés y el director de El Masón Ilustrado, comenzaron
a subir una ancha escalera hasta llegar a las guardillas,
alumbrándose con fósforos.
Llamaron en una puerta, apareció una muchacha que les hizo pasar
a un estudio de pintor y poco después se presentó un señor de
barba y pelo entrecano, envuelto en un gabán.
Este señor Rafael Villasús era un pobre diablo autor de comedias y
de dramas detestables en verso.
El poeta, como se llamaba él, vivía su vida en artista, en bohemio;
era en el fondo un completo majadero, que había echado a perder a
sus hijas por un estúpido romanticismo.
Pura y Ernestina llevaban un camino desastroso; ninguna de las dos
tenía condición para la escena; pero el padre no creía más que en el
arte, y las había llevado al Conservatorio, luego metido en un teatro
de partiquinas y relacionado con periodistas y cómicos.
Pura, la mayor, tenía un hijo con un sainetero amigo de Casares, y
Ernestina estaba enredada con un revendedor.
El amante de Pura, además de un acreditado imbécil, fabricante de
chistes estúpidos, como la mayoría de los del gremio, era un
granuja, dispuesto a llevarse todo lo que veía. Aquella noche estaba
allí. Era un hombre alto, flaco, moreno, con el labio inferior colgante.
Los dos saineteros hicieron gala de su ingenio, sacando a relucir una
colección de chistes viejos y manidos. Ellos dos y los otros, Casares,
Aracil y el director de El Masón Ilustrado, tomaron la casa de Villasús
como terreno conquistado e hicieron una porción de horrores con
una mala intención canallesca.
Se reían de la chifladura del padre, que creía que todo aquello era la
vida artística. El pobre imbécil no notaba la mala voluntad que
ponían todos en sus bromas.
Las hijas, dos mujeres estúpidas y feas, comieron con avidez los
pasteles que habían llevado los visitantes, sin hacer caso de nada.
Uno de los saineteros hizo el león, tirándose por el suelo y rugiendo,
y el padre leyó unas quintillas que se aplaudieron a rabiar.
Hurtado, cansado del ruido y de las gracias de los saineteros, fué a
la cocina a beber un vaso de agua y se encontró con Casares y el
director de El Masón Ilustrado. Este estaba empeñado en ensuciarse
en uno de los pucheros de la cocina y echarlo luego en la tinaja del
agua.
Le parecía la suya una ocurrencia graciosísima.
—Pero usted es un imbécil—le dijo Andrés bruscamente.
—¿Cómo?
—Que es usted un imbécil, una mala bestia.
—¡Usted no me dice a mí eso!—gritó el masón.
—¿No está usted oyendo que se lo digo?
—En la calle no me repite usted eso.
—En la calle y en todas partes.
Casares tuvo que intervenir, y como sin duda quería marcharse,
aprovechó la ocasión de acompañar a Hurtado diciendo que iba para
evitar cualquier conflicto. Pura bajó a abrirles la puerta, y el
periodista y Andrés fueron juntos hasta la Puerta del Sol. Casares le
brindó su protección a Andrés; sin duda, prometía protección y
ayuda a todo el mundo.
Hurtado se marchó a casa mal impresionado. Doña Virginia,
explotando y vendiendo mujeres; aquellos jóvenes, escarneciendo a
una pobre gente desdichada. La piedad no aparecía por el mundo.
IV
LULÚ
y esos otros en que las mujeres entran en quinta, o tienen que ser
marineras, el de la ¿Niña qué?, o el de las mujeres que montan en
bicicleta, en el que hay esa preocupación graciosa, expresada así:
Por eso hay ahora
mil discusiones,
por si han de llevar faldas
o pantalones.
MÁS DE LULÚ
MANOLO EL CHAFANDÍN
Una amiga, con la cual solía prestarse mutuos servicios Lulú, era una
vieja, planchadora de la vecindad, que se llamaba Venancia.
La señora Venancia tendría unos sesenta años, y trabajaba
constantemente; invierno y verano estaba en su cuartucho, sin cesar
de planchar un momento. La señora Venancia vivía con su hija y su
yerno, un chulapo a quien llamaban Manolo el Chafandín.
El tal Manolo, hombre de muchos oficios y de ninguno, no trabajaba
más que rara vez, y vivía a costa de la suegra.
Manolo tenía tres o cuatro hijos, y el último era una niña de pecho
que solía estar con frecuencia metida en un cesto en el cuarto de la
señora Venancia, y a quien Lulú solía pasear en brazos por la galería.
—¿Qué va a ser esta niña?—preguntaban algunos.
Y Lulú contestaba:
—Golfa, golfa—u otra palabra más dura, y añadía: Así la llevarán en
coche, como a la Estrella.
La hija de la señora Venancia era una vaca sin cencerro, holgazana,
borracha, que se pasaba la vida disputando con las comadres de la
vecindad. Como a Manolo, su hombre, no le gustaba trabajar, toda la
familia vivía a costa de la señora Venancia, y el dinero del taller de
planchado no bastaba, naturalmente, para subvenir a las
necesidades de la casa.
Cuando la Venancia y el yerno disputaban, la mujer de Manolo
siempre salía a la defensa del marido, como si este holgazán tuviera
derecho a vivir del trabajo de los demás.
Lulú, que era justiciera, un día, al ver que la hija atropellaba a la
madre, salió en defensa de la Venancia, y se insultó con la mujer de
Manolo; la llamó tía zorra, borracha, perro y añadió que su marido
era un cabronazo; la otra le dijo que ella y toda su familia eran unas
cursis muertas de hambre, y gracias a que se interpusieron otras
vecinas, no se tiraron de los pelos.
Aquellas palabras ocasionaron un conflicto, porque Manolo el
Chafandín, que era un chulo aburrido, de estos cobardes, decidió
pedir explicaciones a Lulú de sus palabras.
Doña Leonarda y Niní, al saber lo ocurrido, se escandalizaron. Doña
Leonarda echó una chillería a Lulú por mezclarse con aquella gente.
Doña Leonarda no tenía sensibilidad más que para las cosas que se
referían a su respetabilidad social.
—Estás empeñada en ultrajarnos—dijo a Lulú medio llorando—.
¿Qué vamos a hacer, Dios mío, cuando venga ese hombre?
—Que venga—replicó Lulú—; yo le diré que es un gandul y que más
le valía trabajar y no vivir de su suegra.
—¿Pero a ti qué te importa lo que hacen los demás? ¿Por qué te
mezclas con esa gente?
Llegaron por la tarde Julio Aracil y Andrés y doña Leonarda les puso
al corriente de lo ocurrido.
—Qué demonio; no les pasará a ustedes nada—dijo Andrés—; aquí
estaremos nosotros.
Aracil, al saber lo que sucedía y la visita anunciada del Chafandín, se
hubiera marchado con gusto, porque no era amigo de trifulcas; pero
por no pasar por un cobarde, se quedó.
A media tarde llamaron a la puerta, y se oyó decir:
—¿Se puede?
—Adelante—dijo Andrés.
Se presentó Manolo el Chafandín, vestido de día de fiesta, muy
elegante, muy empaquetado, con un sombrero ancho torero y una
gran cadena de reloj de plata. En su mejilla, un lunar negro y rizado
trazaba tantas vueltas como el muelle de un reloj de bolsillo. Doña
Leonarda y Niní temblaron al ver a Manolo. Andrés y Julio le
invitaron a explicarse.
El Chafandín puso su garrota en el antebrazo izquierdo, y comenzó
una retahila larga de reflexiones y consideraciones acerca de la
honra y de las palabras que se dicen imprudentemente.
Se veía que estaba sondeando a ver si se podía atrever a echárselas
de valiente, porque aquellos señoritos lo mismo podían ser dos
panolis que dos puntos bragados que le hartasen de mojicones.
Lulú escuchaba nerviosa, moviendo los brazos y las piernas,
dispuesta a saltar.
El Chafandín comenzó a envalentonarse al ver que no le
contestaban, y subió el tono de la voz.
—Porque aquí (y señaló a Lulú con el garrote) le ha llamado a mi
señora zorra, y mi señora no es una zorra; habrá otras más zorras
que ella, y aquí (y volvió a señalar a Lulú) ha dicho que yo soy un
cabronazo, y ¡maldita sea la!... que yo le como los hígados al que
diga eso.
Al terminar su frase, el Chafandín dió un golpe con el garrote en el
suelo.
Viendo que el Chafandín se desmandaba, Andrés, un poco pálido, se
levantó y le dijo:
—Bueno; siéntese usted.
—Estoy bien así—dijo el chulo.
—No, hombre. Siéntese usted. Está usted hablando desde hace
mucho tiempo, de pie, y se va usted a cansar.
Manolo el Chafandín se sentó, algo escamado.
—Ahora, diga usted—siguió diciendo Andrés—qué es lo que usted
quiere, en resumen.
—¿En resumen?
—Sí.
—Pues yo quiero una explicación.
—Una explicación, ¿de qué?
—De las palabras que ha dicho aquí (y volvió a señalar a Lulú)
contra mi señora y contra este servidor.
—Vamos, hombre, no sea usted imbécil.
—Yo no soy imbécil.
—¿Qué quiere usted que diga esta señorita? ¿Que su mujer no es
una zorra, ni una borracha, ni un perro, y que usted no es un
cabronazo? Bueno; Lulú, diga usted eso para que este buen hombre
se vaya tranquilo.
—A mí ningún pollo neque me toma el pelo—dijo el Chafandín,
levantándose.
—Yo lo que voy a hacer—dijo Andrés irritado—es darle un silletazo
en la cabeza y echarle a puntapiés por las escaleras.
—¿Usted?
—Sí; yo.
Y Andrés se acercó al chulo con la silla en el aire. Doña Leonarda y
sus hijas empezaron a gritar; el Chafandín se acercó rápidamente a
la puerta y la abrió. Andrés se fué a él; pero el Chafandín cerró la
puerta y se escapó por la galería, soltando bravatas e insultos.
Andrés quería salir a calentarle las costillas para enseñarle a tratar a
las personas; pero entre las mujeres y Julio le convencieron de que
se quedara.
Durante toda la riña Lulú estaba vibrando, dispuesta a intervenir.
Cuando Andrés se despidió, le estrechó la mano entre las suyas con
más fuerza que de ordinario.
VII
HISTORIA DE LA VENANCIA
ebookgate.com