9781430237891_CO-01.jpg

Chapter 1

Introducing the Past, Present, and Future of the Web

Believe it or not, when we were kids the standard way to send a message to a friend or family ­member was by mail. Not e-mail, mind you, but the physical kind requiring a stamp on the envelope. Fax machines came blazing onto the scene and revolutionized communications because, all of a sudden, you could send a document across the country in a matter of minutes, rather than a number of days. Personal computers were starting to show up in houses, but they generally cost an arm and a leg, and they certainly did not have any sort of way of communicating with the outside world. For the most part, assignments in school were handwritten, unless you had a typewriter at home! It was just the standard.

Most people in their twenties today will have a hard time believing that the Internet is a reasonably new invention, and the World Wide Web is even newer. Yet both have had as profound an impact on civilization as the printing press, the steam engine, or the light bulb. When we were growing up, we had an impossible time finding good video games for our PCs. Computers were all about business then. It was easy to find six different word processors, but nearly impossible to find the latest release from Sierra Online (which is owned by Electronic Arts now). These days, if you are looking for a video game, where do you go? The average person will head over to Amazon and preorder their copy of the latest title for next-day shipping. E-commerce has become so ubiquitous that, for certain products, it is preferred over a trip to the local store.

Even between the time that the first edition of this book was written and now, big changes have taken place (and that was just three years ago!). For example, there is now a really good chance that you are not even reading this book in a paper format! You might be using a tablet like an iPad or Playbook, an eReader like Amazon’s Kindle, a PDF on your notebook or desktop computer, or even reading this on your cell phone. I have to tell you, it is really an experience to step back and think that in my lifetime, I have gone from a place where 1 in 1,000 households had access to a computer to now, where computer ownership may have peaked and people are moving to simpler, easier devices.

The standard way of doing things

Because of its highly technical childhood, the World Wide Web has a lot of “hacker baggage.” When we say that, we don’t mean that it’s a dangerous place where people roam the wires trying to steal your credit card information (although there is some of that, too). We’re using the term hacker in the classic sense of someone who has a curiosity about technology and tries to find her own way of solving problems. The Web started off very much from a position of trying to solve a problem: distributing research information. It evolved and gained features out of necessity—people needed to be able to add images and tables to their documents. In the early days of mainstream adoption, when businesses started to move online, there wasn’t always a perfect way of doing things, so people came up with their own solutions.

A classic example of this is using a table on a web page to lay it out. At one point, we were guilty of this; but at that point we had no choice. Using a table was the only way we could get two columns of text to display on a page side by side. Things are vastly different today, and most would agree that the layout of a page is something better handled in the style information, rather than in the page’s markup itself. Web standards have evolved; this isn’t 1995 anymore, nor is it even 2005. Things have changed—and, dare we say—improved!

Every journey starts with a single step: the Web past

It is hard to find a book about Hypertext Markup Language (HTML) and the Web these days that doesn’t start off with a history section. We used to wonder why that was the case. To understand why the web standards approach to building websites is the best way to go, you have to know about the progression of the World Wide Web and how it evolved to become what it is today. The World Wide Web has very technical roots, and the trouble (or charm) with most techies is that they like to customize and change things until those things are perfect in their minds. They cannot follow what everyone else is doing; they need to add their own flavor to it.

The Web started its life as a research project at CERN (the European Organization for Nuclear Research) in Geneva, Switzerland. At the time, a researcher there by the name of Tim Berners-Lee was looking for a way to quickly and easily share research findings with his peers and organize information in such a way that it would be easy to archive and retrieve. Although the process was started in the early 1980s, it wasn’t until 1990 that Berners-Lee produced the first web server and web browser (which was called WorldWideWeb, the origin of the name).

In 1992, the Web began to hit the mainstream when the National Center for Supercomputing Applications (NCSA) in the United States released Mosaic, which was capable of displaying text and graphics simultaneously. Mosaic gave nonscientists easy access over the Internet to documents created using HTML, what we now call web pages. Encouraged by this early success, one of Mosaic’s creators, Marc Andreesen, left the NCSA and started Mosaic Communications Corporation. This later became Netscape Communications Corporation, which created Netscape Navigator, the first commercial browser and the web standard-bearer through most of the 1990s.

A company called Spyglass licensed NCSA’s source code and eventually released Spyglass Mosaic (although on a newly developed code base). This became the basis for Microsoft Internet Explorer, and it set the stage for the battle for browser supremacy between Netscape and Microsoft.

Just prior to the start of the “browser wars” of the 1990s, Berners-Lee recognized that, without some sort of governance, the World Wide Web would experience great challenges as competing web browsers introduced new features. One of the ways to get someone to pick your product over your competition was to offer a bunch of really cool features that the other guy didn’t offer. He foresaw compatibility problems emerging as competing companies introduced their own tags in order to add features to the World Wide Web. HTML was the glue binding the Web together, and some central body would need to oversee its evolution in order to maintain a high level of interoperability.

Microsoft gave away Internet Explorer as part of Microsoft Office, bundled it with Windows, and made it available as a free download for all its various operating systems, as well as for Macs. Microsoft was a late starter in the browser market; and by the time it entered the game in 1995, Netscape had an estimated 80 percent market share. The tides rapidly turned, however. By the time Netscape was acquired by America Online in 1998, Microsoft had approximately half of the web browser market. By 2002, Internet Explorer reached its peak with an estimated 96 percent of web surfers using Internet Explorer. In fact, Microsoft so thoroughly thrashed Netscape in the browser wars that the companies ended up in a contracted lawsuit. Eventually, this led to a finding that Microsoft had abused its monopoly power in the marketplace. Figure 1-1 shows a timeline of major browser releases, starting in the early 1990s.

9781430237891_Fig01-01.jpg

Figure 1-1. Timeline of major browser releases

The browser wars were an incredibly difficult time for web developers as manufacturers raced to do their own thing. Versions 3 and 4 of the major browsers often had developers coding two entirely separate versions of their websites in order to ensure compatibility with both Internet Explorer and Netscape. Although web standards existed, most browsers only really supported the basics and relied on competing (and incompatible) technology to do anything advanced, which is what web developers wanted to do.

Netscape, although owned by a fairly major company, started to stagnate. Netscape open sourced its code base, and the Mozilla project was born. The Mozilla community took off with the code and started to really implement standards support in a new way through a complete rewrite of the rendering engine. Although Mozilla was initially based on Netscape Navigator, the tables rapidly turned, and subsequent releases of Netscape became based on Mozilla.

The Mozilla project has forked into a number of new browsers, most notably Firefox , which has sparked a new browser war with Microsoft. Yet this time, the battle has had a positive effect. Microsoft had all but stopped working on Internet Explorer once it released version 6. When Firefox hit the scene with near-perfect support for web standards, it became an immediate hit and gained a great deal of popularity with both the web cognoscenti and the general public. It seems as though Microsoft had no choice but to improve its web browser, and the result is Internet Explorer 7.

A number of other players emerged in the web browser marketplace, offering competition to the major players. Notably, Opera has always touted excellent support for web standards as one of its major selling features. It has caught on to some degree (2.4 percent as of January 2012), and it is also focusing in large part on mobile devices.

Safari by Apple Computer hit the scene in 2003, and it quickly became one of the most popular choices for Mac users because it integrates well with the operating system and is generally faster than competing browsers on the Mac. Apple introduced a Windows version in 2007. One of the most unique qualities of Safari is that, even with its minor updates (so-called point releases), the browser has improved its support of web standards. This is something that is often relegated to major releases among other browser manufacturers.

Another 800 pound gorilla joined the browser race when Google came on the scene with Chrome in 2008. Chrome took things in a completely different direction and has really shaken up the web browser scene. For the first time since the late nineties, a web browser was created that focused on speed, stability, and security, putting features on the backburner. Sure, Chrome has great standards support and is usually even ahead of the curve when it comes to supporting emerging standards; however, the folks at Google (at least at first) ignored the race to add more to their browser, and instead focused on delivering a blazing fast experience, something that has really resonated with a number of people.

Then there were standards: the Web now

Imagine if each TV channel was broadcast in either PAL or NTSC in each country, requiring viewers to use a different TV set, depending on what they wanted to watch. Or, imagine writing a research paper, running a search on Google, and then having to open each of the results returned in a different web browser. For example, you would open the first link is Internet Explorer, but the second and third links in Netscape. And for the next link, you would be back to Internet Explorer. Yet, this is pretty much how things worked in the late 1990s. Developers either produced parallel versions of their sites or designed for one specific browser. One of the most common sights on the Web was these wonderful (heavy sarcasm here) graphic badges telling visitors that a given website was “Optimized for Internet Explorer” or “Best Viewed with Netscape Navigator” (see Figure 1-2).

9781430237891_Fig01-02.jpg

Figure 1-2. The “get it now” buttons for Netscape Navigator and Internet Explorer

When we talk about web standards, we’re generally referring to the big three players on the Web: HTML (or XHTML), Cascading Style Sheets (CSS), and JavaScript. The World Wide Web Consortium (W3C) maintains many other standards, such as Scalable Vector Graphics (SVG) for vector graphic display, Portable Network Graphics (PNG) as a way to compress bitmap graphics, and Extensible Markup Language (XML), which is another markup language that is similar in a lot of ways to HTML.

While "HTML/XHTML is all about structuring your document, CSS handles enhancing the user experience through formatting and some interactivity. Because they’re two separate pieces of technology, you can physically separate them (by keeping your markup in one file and your style declarations separately in another). The early versions of HTML (prior to the release of CSS) were intended to be everything to everyone. The ability to specify colors and fonts was built right in by specifying the attributes of various tags. As sites began to grow in size, however, the limitations of going this route quickly became apparent.

Imagine that you have put together a website to promote this book. Throughout the site, which covers all the chapters in detail, there are quotes from the book. To really make these quotes jump off the screen, you decide to put them in red and make them a size bigger. In the good old days, your code would look something like this:

 <font size="+1" color="red">In the good old days,

 images your code would look something like this:</font>

With a little HTML and CSS, the code could look like this (note we said “could” because there are multiple ways of doing things—including the old way—but this is a good, structurally relevant example):

 <blockquote>In the good old days,

 images your code would look something like this:</blockquote>

And then, in a separate CSS file (or at the top of your HTML document—but again, that’s just another option), you could import/link to pages of your website, which would look something like this:

 blockquote { font-size: 1.5em; color: red; }

So what? They both do the same thing. Web browsers will display the quotes in red and make them nice and big. One of the immediate advantages, however, is in making updates. As we mentioned previously, you are liberally quoting the book throughout the entire website, chapter by chapter. By the end of the project, you discover that you have used more than 300 quotes! The only problem is that we, as the authors (and your client), absolutely hate red text. It makes us so angry. So, we’re going to ask you to change it everywhere.

What would you rather do: update one line in the CSS file or open every page on the site and change the color attribute to blue? (Blue is much more calming.) Three hundred quotes—you’re billing by the hour—so that’s not so bad. It’s maybe an extra half day of work. Now extrapolate this example to something like the New York Times where there are quite likely millions of quotes throughout the entire website. Are you still keen to go change every font tag on every page?

You might be thinking to yourself, “My software can do search and replace.” This is true. We were once asked to update a department website at an organization where we worked. The website had about 16,000 pages; and by the end of a week, our search and replace still hadn’t finished. We’re not that patient. Are you?

Ease of updating aside, separating content from presentation in this way will help you to maintain consistency across a site. Did you have those quotes set at 1.5em, or 1.2em? It can be hard to remember day after day, week after week, just what sort of formatting parameters you have set up for every bit of text on your web site—so why not remove your memory from the equation? It’s far easier to define a set of style options that can be applied to your document.

Additionally, CSS has evolved and is still evolving, allowing designers and developers to do more and more in terms of the layout and appearance of their pages. Using CSS3, you can position any element anywhere you like on a page and set the opacity of that element (if you have ever used layers in Photoshop, I think you can quickly see the possibilities with this). Although you could probably accomplish the same thing with a table-based layout and transparent graphics, it would probably require you to write a considerable chunk of code in which you would need to set absolute heights and widths of table cells, not to mention all of the time needed to generate and regenerate the graphics as you work through a design.

CSS3 has even more formatting options baked in. It lets you specify multiple background images for an element, set the transparency of colors, allow certain elements to be resized on the fly, and even to add drop shadows to text and other elements on the fly. CSS3 takes things one step further by branching out from simple formatting into the “experience” layer. CSS3 lets you perform transforms and transitions on elements; for example, you can rotate and scale them dynamically. Check out the W3C website for more information; or, for a slightly easier to follow format (that includes examples), visit www.CSS3.info for more information.

The example described previously is a pretty simple representation of what you can do using HTML and CSS. If you head over to the CSS Zen Garden ( http://CSSzengarden.com/ ) and click through some of the examples there, you can gain an appreciation for the level of control you can achieve by tweaking the CSS for a website. CSS Zen Garden uses the same markup for every example (the XHTML part stays the same on every page). The only thing that is different on each page is the CSS file that is included, as well as any supporting graphics (see Figure 1-3, Figure 1-4, and Figure 1-5).

9781430237891_Fig01-03.jpg

Figure 1-3. An example from CSS Zen Garden (Make ’em Proud), which you can find at www.CSSzengarden.com. It uses the same XHTML markup as Figures 1-4 and 1-5, but each page is styled using different CSS style sheets and images.

9781430237891_Fig01-04.jpg

Figure 1-4. This is the same page as shown in Figure 1-3, but styled using an alternate style sheet (Orchid Beauty) at the CSS Zen Garden.

9781430237891_Fig01-05.jpg

Figure 1-5. A final example (CSS Co., Ltd.) that shows just how powerful CSS can be for changing the look of a page.

Imagine not having to touch a single page of markup when redesigning a website and still getting a completely different end result. Properly structured, standards-based pages will let you do that. This could be a major advantage for companies building large-scale content management systems: simply change the style sheet, and the CMS has been tailored to a new customer. Some companies are doing this, but others haven’t caught on to this, yet.

A crystal ball: the Web future

The Web is a cool place in many ways, not least because we don’t need to be a fortune-teller to see into the future. Because standards take time to develop, we already have an idea of what the future holds. HTML5 is the new hotness, but it is still an evolving standard in the world of markup. The majority of the specification has now been defined with the goal of tying up a lot of the loose ends from HTML 4 and bridging the gap with the world of XHTML.

The W3C process for standards approval goes through numerous steps, and it can easily span several years. The final product of this process is a W3C Recommendation. Because the W3C isn’t a governing body, all it can do is make a recommendation that software companies can then choose to follow. There are no “laws” of the Web; so if Apple were to decide it wants to drop HTML support in Safari in favor of its own markup language, it could. As you can see from our previous history lesson, this wouldn’t have been completely out of the question in the 1990s; but today, it would probably be very self-defeating. The culture of the Web is all about interoperability; and when companies attempt to limit interoperability to gain some sort of competitive advantage, we all lose.

This has led to somewhat mixed results. On one hand, you can go to almost any website and have it work in almost any web browser. There are still some companies that are pulling the old “Please download Internet Explorer” trick, but those companies are few and far between (my bank just pulled this the other day on me, and I am now looking for a new bank). The fact of the matter is that interoperability, for businesses, means a larger potential customer base. For most Mac users, if they visit a website that is “Internet Explorer–only,” they’re dead in the water. This is true for mobile users, the fastest-growing segment of Internet users, as well. Sure, they could all buy a Windows machine or run some virtualization software to make it work; but chances are, if they have the choice (and the Web is all about choices), they just won’t bother. They’ll go find a competitor that supports Chrome, Safari, or Firefox.

The consultation process for developing new standards and revising old ones is very thorough, and it involves a lot of consultation with the community. Several drafts are developed, a great deal of feedback is collected, and eventually a Recommendation is put forth. We’ve presented HTML and XHTML almost interchangeably in this first chapter. And while both HTML and XHTML are valid web standards, in this book we’ll focus on HTML5, the latest in a long line of markup language recommendations.

HTML5 was originally targeted at web applications with an eye to improving speed, compatibility, and the ease with which you can construct them. It introduces a number of new elements and relaxes some of the strict rules around markup in XHTML, making it easier to learn than its predecessors. HTML5 also attempts to minimize the need for a lot of third-party plugins for displaying content.

What’s inside this book?

Our goal is to take this book beyond web standards to cover the entire process of developing a website based on standards. Believe it or not, there is more to putting together a great website than just knowing a little HTML and CSS. This introduction will expose you to different techniques and technologies, and we hope it will encourage you to pursue those areas you find most compelling.

The publishing industry as a whole is changing and evolving. Websites, and other electronic publishing media are becoming more and more prominent as they drive costs down, facilitate and speed up the process of creating content, and allow instant delivery of that content. This is having a profound effect in a number of related industries as advertising dollars are shifted out of newspapers and magazines toward online venues.

Technologies come and go or—as in the case of HTML—evolve. Three years ago, we wrote that “Two years from now, we may have to completely rewrite sections of this book.” That has proven itself true! While everything in the original edition of this book will still work, the techniques presented there are not the fastest, easiest, or best ways to do things anymore. It’s exciting to be working with ever-changing Internet and web technologies. When the original edition was written, the mobile web was just on the horizon and hadn’t fully developed. There’s no telling what we’ll find around the next corner.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset