For Manda, my better half. This book would not have been possible without your continued support. All my love, Lloydi.
Preface
Congratulations on buying this book. Oh, wait a minuteperhaps youre yet to buy it. Perhaps youve just picked up this book in your local bookshop, and are trying to decide whether its 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. Its all about getting it right the first time and not learning bad habitsbad habits that you have to unlearn at a later datefor the purpose of a quick result.
Lets 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 and in what order, and then drive off without hitting anything. Meanwhile, other more experienced people just jump into their cars, start the engine, and drive from A to B without really thinking about what theyre 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 beginningfollowing 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 to ignore the speed limit signs, to put your foot down because the road is clear, or that the one-way sign wasnt important at that time of night. Itd be a miracle if you passed your driving test, and chances are those bad habits would stay with you (so long as you could manage to keep your license).
Learning to build web pages can be a bit like that.
Ive been designing and building websites for over ten years now, but I can clearly remember the joy of creating my first site. Admittedly, in hindsight, it was quite a nasty-looking website, but it achieved the goal at the timeI had published a website, 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 websites.
At the time, there were a limited number of books available that provided what I wanted, but I lapped up everything I could find, learning some tricks from books, and gaining other ideas from visiting websites. But then I discovered that Id been doing it all wrong. The books Id learned from had given me what later turned out to be poor advice, while the websites Id 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 to properly embrace the technologypublishing home pages and developing online corporate presences for their companiesthey all realized quickly that the medium was limited. Necessity 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. Browsers helped along the way, 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