04_274361-ch01.qxp 4/17/08 2:55 PM Page 2

Introducing HTML

ess than twenty years after its invention, the contributed to the growth of the Web, but one of the most World Wide Web has become ubiquitous. Today, important is that Hypertext Markup Language (HTML), there are tens of billions of Web sites worldwide, the language in which Web pages are written, is easy to L learn, and best of all, free. and the number continues to grow at an almost exponential rate. There are many factors that have

History of HTML

The World Wide Web was invented in 1990 by Tim Berners- Berners-Lee developed HTML by combining these two Lee. Berners-Lee worked at the European Particle Physics concepts: He took the idea of hypertext and applied it via Laboratory (CERN) in Geneva, and at the time, no one SGML. He also developed the Hypertext Transfer Protocol had come to dominate the market. Therefore, (HTTP), which allows networked computers to exchange the visiting scientists at CERN were bringing in their own HTML documents, and the first browser/editor, which he computer systems, and despite the fact that they were working called WorldWideWeb, a name later adopted for the entire together on cutting-edge technologies, they had no real way to system. share their data with one another except on paper. The first time Berners-Lee used these new technologies was In the 1960s, scientists at IBM developed the Standard on Christmas Day, 1990. It took several years to really catch Generalized Markup Language (SGML), which is a language on, but by 1995, new companies such as Yahoo! and for creating other languages. Also in the 1960s, researchers Amazon.com were founded, and along with the Netscape at Brown and Stanford Universities developed hypertext, a browser, the Web quickly took off from there. method of relating similar information.

Versions of HTML

HTML went through several iterations in the early days when Realizing that what had begun as a fairly simple text markup only a few people, mostly at universities, were using it. language was fast becoming too complex to manage, the Berners-Lee first publically promoted the concept of HTML World Wide Web Consortium (W3C), the body that had been online in 1991, but it was not until 1993 that the Internet established to manage the development of future versions of Engineering Task Force formally adopted an HTML HTML and other Web-related technologies, released HTML 4 specification as a “working draft.” Two years later, they in 1997. This marked an attempt to find a common ground published the HTML 2.0 specification (note that, technically, between the needs of future developers to have an easy-to- there was never an HTML version 1.0). use and easy-to-learn yet robust language while preventing the then-millions of existing pages from breaking in newer HTML 3.0 was proposed in 1995, but was deemed too complex COPYRIGHTEDbrowsers. MATERIAL The goal of this new version was to encourage Web for implementation by browsers. It was fairly quickly designers to move away from the bloated, browser-specific supplanted by HTML 3.2, the first truly popular version of the code they had been forced to write and instead return their language. Unfortunately, version 3.2 introduced a host of HTML documents to the original ideas of the language; they browser-specific elements and attributes that had been adopted would then focus solely on the underlying structure of the by browser manufacturers such as Netscape and Microsoft, document instead of visual formatting, which would now be creating challenges for Web designers who wanted to create handled by Cascading Style Sheets (CSS), the newly- pages that would correctly display across multiple browsers. developed formatting language of the Web.

2 Chapter 1: Introducing HTML and XHTML 3 . Some use an opening tag, which , as they do not contain content. container tags empty tags Some text to be made bold- faced While the majority of tags are containers, there are a While the majority of tags are containers, there to set of tags that essentially represent instructions closing tag. and thus have no matching the browser, need to For example, while it makes sense that you text, it tell the browser where to begin and end bold tell the likewise makes sense that you only need to logical browser where to place an image — it has no are end point, and therefore no closing tag. These called Most HTML tags will surround a block of text, thus Most HTML tags will surround use elements that describe marking it up. These tags needs to begin, and when it both when the markup want to make some text ends. For example, if you the browser both when to begin bold, you need to tell when it should stop doing making the text bold and so. These has the element and the angle , and a has the element and the angle brackets, and forwardcorresponding closing tag, which includes a slash after the opening bracket and before the element. Container and Empty Tags Container and Empty 4.01 Strict requires that only structure-based code be requires that only structure-based 4.01 Strict by CSS. The third, less all formatting handled used, with allows developers HTML 4.01 Frameset commonly-used frames for page layout. to create pages that utilize element is . opening angle bracket. Within tags, the element must immediately follow the html . Attributes appear after . can and attribute values. You can use any case you want for elements, attributes, You , which describe to the attributes elements . figure out which cases require them and which do not. After that, however, you can put as much space as you wish, including carriage returns, between the element and After that, however, can use any whitespace any attributes, between attributes, and before the closing bracket. Outside of tags, you display in your characters, again including carriage returns, within your content without affecting the final and always ignore tabs and Browsers always ignore more than one consecutive whitespace character, browser. carriage returns. quotation marks When using attributes, you can enclose the value of the attribute in single or double them rather than tryattribute values need not have quotation marks at all, but it is easier to simply always use to HTML is case-insensitive also freely mix and match cases, but being consistent will make your code easier to read. HTML is whitespace-insensitive • • • the element but before the final angle bracket in an the element but before the final angle bracket name, opening tag. Attributes consist of the attribute in an equal sign, and a value, which will be enclosed quotation marks. Note that attributes are never repeated in the closing Note that attributes are never repeated in the in tag, and whenever you use more than one attribute a single tag, they can be presented in any order. which image to display. This additional information for This additional information which image to display. tags is given through There are times when you need to expand on the There are times when you need to expand on it information you are providing in a tag. For example, you want is not enough to simply tell the browser that tell it to display an image on the page; you need to While I have already noted that HTML uses a very loose syntax, there are still a few things about which you need to be aware. HTML is made up of browser how a particular piece of text should be browser how a particular expressed in HTML as tags, treated. Elements are surrounded by angle which consist of the element than and less than symbols. brackets, or the greater uses the An example of a tag that designers to move from the presentation-heavy code of move from the presentation-heavy designers to using CSS for formatting. HTML earlier HTML and begin HTML 4 (and the update version 4.01) has three versions. the update version HTML 4 (and require, but does not encourages, Transitional HTML 4.01 Attributes HTML Syntax Rules HTML Elements and Tags HTML Elements and The “Flavors” of HTML 4.01 The “Flavors” 04_274361-ch01.qxp 4/17/08 2:55 PM Page 3 Page PM 2:55 4/17/08 04_274361-ch01.qxp 04_274361-ch01.qxp 4/17/08 2:55 PM Page 4

Introducing XHTML 1.0

hile development of HTML continued, the To provide Web designers with the tools they needed to W3C was also hard at work on another be better able to troubleshoot pages, the W3C released markup language. The Extensible Markup Extensible HTML (XHTML) 1.0, ultimately intending that W it replace HTML 4.01. XHTML uses the same set of Language (XML) was designed to allow developers to create documents that focused solely on the actual elements and tags as HTML, and even includes the same data of their page, without regard to how such data three “flavors” — Transitional, Strict, and Frameset. might eventually be displayed. XML relies on a much However, it requires that pages be written in the much stricter syntax than HTML. While beginners may find stricter XML syntax. the loose syntax of HTML easy to learn, languages with stronger syntaxes are ultimately easier to debug and manage.

XHTML Syntax Rules

Although HTML and XHTML share a set of elements, there are several important differences between the syntaxes of each: • XHTML is case-sensitive. All elements and attributes must be lowercase. • XHTML requires that attribute values be quoted. You can use single or double quotation marks, but you must always use them. • XHTML requires that all attributes have values. While rare, there are a few scattered examples of HTML attributes that have no value, and instead use a single word. In XHTML, these must have a value, which is always the name of the attribute repeated as the value. An example is the input element, used for forms (see Chapter 11 for details). When the input element is used to create a radio button, and you wish to have the button selected by default, HTML uses the checked attribute. In XHTML, it is written checked=”checked”. • XHTML requires that tags be properly nested. It is almost always possible to nest tags within other tags. For example, much of the content on your page will be in paragraphs, which use the p element. Within a paragraph, you may have text that you want to be both bold (using the strong element) and italic (using em). The code in this case would be

Some bold, italic text.

. Here, the em tag is nested within the strong, which is in turn nested within the p. This is the proper XHTML syntax, where the tags close in the opposite order from which they were opened, and each element is completely nested within the other. HTML would allow for

Some bold, italic text.

, where the order of the closing tags is reversed. • XHTML requires closing tags. As was discussed previously, HTML has container tags that surround marked-up text and empty tags that merely give an instruction to the browser. In XHTML, even empty tags must be closed. You can either add the closing tag immediately after the opening, as in , or simply add the forward slash before the closing angle bracket: . Either is allowed, but the latter is preferred if for no other reason than it takes less code.

The one syntax rule that is the same between HTML and XHTML is that both are whitespace-insensitive.

4 04_274361-ch01.qxp 4/17/08 2:55 PM Page 5 Chapter 1: Introducing HTML and XHTML Declaring the “Flavor” of XHTML

For your XHMTL document to be considered valid, you The XHTML Strict DOCTYPE: must begin the document with a document type complex at first, they will always be exactly the same on The XHTML Frameset DOCTYPE: every document that uses that type, so you can simply copy and paste them from one document to the next.

Declaring the XHTML Namespace Advantages of XHTML

Because XHTML documents are technically written in Writing XHTML only requires a small amount of XML, it is necessary to also define the XHTML additional effort beyond writing HTML, and yet it namespace for your document. This is a fairly provides several advantages. First, you can validate technical XML detail, and fully understanding its XHTML documents using one of several free online purpose is not necessary, especially considering that, resources. Browsers will not throw errors or attempt to like the DOCTYPE, it will always be the same on every inform you in any way when they encounter mistakes one of your documents (regardless of which in your Web page coding. Instead, they will simply DOCTYPE you are using). It is added as an attribute to ignore any elements or attributes they do not the first tag in your page, which uses the html understand and continue trying to render the page as element: best they can. Unfortunately, this can make troubleshooting problem pages difficult. XHTML . documents with a proper DOCTYPE declaration can be checked against a validator, which lets you know if there are problems and allows you to fix them. Second, XHTML requires that you write better, cleaner code, which will prove much easier to edit and maintain later. Third, XHTML is “future-proof,” meaning that because you declare the version of the language you are using right from the beginning, browsers into the distant future should be able to correctly render your pages. Writing XHTML Strict documents also allows you to separate the content of your page, the XHTML, from the presentation of your page, the CSS, giving you much more flexibility in your designs. This topic is explored in greater detail throughout this book.

5 04_274361-ch01.qxp 4/17/08 2:55 PM Page 6

Introducing Cascading Style Sheets

he W3C developed CSS in an effort to provide a whether you are using HTML or XHTML, and regardless more robust formatting language for the Web. CSS of the DOCTYPE you choose. T can be used with any Web page, regardless of Versions of CSS

The original specification of CSS, version 1.0, was released at Version 2.0 was adopted about eighteen months later. Its the end of 1996. It introduced text formatting, including bold most useful additions were most of the positioning properties and italic typefaces, indents, and spacing; the ability to add used for page layout and media types that allow designers to foreground and background colors to elements; alignment for target style sheets to specific uses. most elements; and margins, padding, and borders on elements. Version 3.0 is still under development by the W3C, with no specific timeframe for adoption.

Browser Support for CSS

Perhaps the most commonly cited reason for not adopting support some features in CSS 3.0, although they do so CSS is concerns over browser support. While these concerns sporadically. were at one time well justified, today few browsers lack significant support for CSS. However, not all browsers implement CSS exactly according to standards, so there are still significant differences in the Of the major browsers on the market today, all fully support ways in which pages may render. It is absolutely imperative CSS 1.0, and all support most if not all of the properties in that, as a Web designer, you test each of your pages on a CSS 2.0. In fact, some browsers such as Firefox even variety of browsers to ensure that it functions properly.

Basic CSS Syntax

CSS relies on a completely different syntax from XHTML. declaration is separated from the next by a semicolon. The Instead of elements and tags, CSS uses rules, which are whole set of declarations is enclosed in curly braces: made up of a selector and declarations. p { color: #ff0000; font-weight:bold; } The selector is a reference to the portion of the XHTML CSS selectors are case-sensitive, while the declarations are document that should be formatted. The selector can be an case-insensitive. CSS is whitespace insensitive. XHTML element, or a special CSS selector such as an ID or class. ID and class selectors will be discussed in Chapter 9. Properties that contain more than one word, such as font- weight, separate the words with hyphens. If a property value Declarations are made up of property-value pairs. Each needs more than one word, such as in the name of a font like property is separated from its value by a colon, and each Times New Roman, that value needs to be in quotation marks.

Inheritance

XHTML documents are made up of nested sets of elements, if you have a paragraph that contains a span, the span will creating parent-child relationships. Many, but not all, CSS inherit most of the parent’s properties, especially those properties inherit from parent-to-child elements. For example, regarding text and font styles.

6 Chapter 1: Introducing HTML and XHTML 7 . property, so property, would be dark blue, font-weight from the more-specific rule, which appears within an heading @import rule but would also be bold, as the more- color:#000099 formatting on your entire site from a central location on your entire site from formatting possible to reformat file. Therefore, it is — your CSS individual having to dig into your site without an example of this can find content pages. You which is a site capability at www.csszengarden.com, page with many different that presents a single formats, all using CSS. You can repurpose your site without rewriting it can repurpose your site You more users are viewing pages These days, more and as cell phones. This creates on alternate devices such and a unique opportunity to both a unique challenge is in designing pages that designers. The challenge widescreen computer can look good on a 19-inch phone screen. By having all display and a 3-inch cell switch of your presentational code in CSS, you can one layouts dynamically as your users move from device to the next, again without having to rewrite any of your underlying XHTML. p {color:#999999; font-weight:bold; } p {color:#999999; font-weight:bold; p#heading {color:#000099; } • XHTML style tag: The second method is to import your style sheet through the special CSS For example, take the following two rules: the less-specific rule using the element selector applies. the less-specific rule using the element selector enables you to force certain properties to be overridden. enables you to force A paragraph with an ID of p#heading The two methods are not mutually exclusive. If you use both, rules in the imported style sheet will take precedence over rules in the linked style sheet, which using the specific rule does not state a . rel , and the value of . your By separating . stylesheet specifies how conflicts are resolved. text/ . Some examples include the ability to add . Some examples include cascade is always element: You can reformat an entire site You the content and your presentation, you can change Because your XHTML documents are smaller when Because your XHTML documents can download the pages you use CSS, the browser it contains only the code more quickly; and because it renders more quickly as well. needed for the content, site see an even bigger Subsequent pages in your speed increase, because the CSS document has already been downloaded and cached by the browser. CSS provides many formatting options not available CSS provides many formatting in HTML colors to any element, borders and background lines, override default control the spacing between implement layout controls. formatting options, and and render more quickly Pages that use CSS load • • • general element. Only declarations directly in conflict will general element. Only declarations directly in be overridden, so a declaration from a less-specific is silent on selector will apply if the more-specific selector that property. Style rules that are closer to the element in question take Style rules that are closer to the element in specific Also, more precedence over those farther away. that rules override less specific rules, so an ID selector over a targets one specific element will take precedence type an XHTML page. The more common is to use the XHTML link All three attributes are required. The value of the attribute is almost always Keep your style sheet information in a separate document. This separates content from presentation, a key consideration behind the development of CSS. It also enables you to apply the same style sheet to multiple pages, site. so you can create one design for your entire Web CSS provides for two ways to attach a CSS style sheet to As you build your style sheets, you will encounter many As you build your style sheets, you will encounter rule instances where you have more than one style In these applying to the same element on your page. cases, the While it is more difficult to learn CSS formatting than difficult to learn While it is more it: advantages to using there are many HTML formatting, Linking and Importing The Cascade Advantages of CSS Advantages 04_274361-ch01.qxp 4/17/08 2:55 PM Page 7 Page PM 2:55 4/17/08 04_274361-ch01.qxp 04_274361-ch01.qxp 4/17/08 2:55 PM Page 8

Introducing JavaScript

n the early days of the Web, a need arose to allow most popular browser, developed a scripting language for designers to provide some sort of interactivity for that purpose. I their users. Netscape, at the time the developer of the

A Brief History of JavaScript Running JavaScript

JavaScript was first introduced in Netscape version 2 in In order to run, your JavaScript code must be interpreted 1996. It was originally called LiveScript, but as Netscape by an application. In most cases, the application being was also adding support for to the browser, they used to run it will be a Web browser. However, many other decided to change the name. Several months later, applications support JavaScript in some form today, Microsoft introduced their version of the language, called including Adobe Reader, which can interpret scripting JScript, along with (IE) version 3.0. contained in Portable Document Format (PDF) documents. JScript was intended to be compatible with JavaScript, Some commercial applications rely on the language to with a different name simply to avoid trademark issues, implement many aspects of the program itself. For although it did introduce several new features. example, many of the dialog boxes in CS3 are written in HTML, with their functionality provided Later, Microsoft submitted JScript to Ecma International, by JavaScript. an organization that develops and maintains standards for computer systems. Today, both JavaScript and JScript try to maintain compatibility with the standardized version, which is called ECMAScript, although both still retain certain variations from the standard.

Writing JavaScript Browser Support

JavaScript is text-based, and can be written in any text Every major modern browser offers full support of editor. Any editor designed to assist in writing Web pages JavaScript. Microsoft’s IE officially supports ECMAScript, is likely to provide help in the form of code hints and but this in effect means it supports JavaScript. Non- for JavaScript. Microsoft browsers tend to claim to not support JScript, although that language’s close relationship to ECMAScript means that other browsers effectively do support it.

JavaScript Is Not Java

Java is a very powerful object-oriented programming browsers. Except for the name, the two languages in fact have language from Sun Microsystems. JavaScript is a scripting absolutely nothing in common. While it is common for language. Java is designed to allow developers to create full beginning Web designers to confuse the two, care should be desktop applications, and in fact many of the applications that taken not to as there is no help available for Java that would you run on your computer are likely written in Java. be useful for JavaScript programming, and vice versa. JavaScript is designed to enhance the capabilities of Web

8 Chapter 1: Introducing HTML and XHTML 9 Ajax, or Asynchronous JavaScript and XML, was Ajax, or Asynchronous JavaScript and XML, on developed as a way to allow developers to extend its the concepts of DHTML while fixing many of problems. Most Ajax development is done through time in pre-built JavaScript libraries, saving developers widely more having to rewrite code. The better, adopted libraries focus on good usability and and also provide many features accessibility, previously unavailable, such as the ability for page. JavaScript to refresh only a portion of a Web The extremely popular Google Maps application (http://maps.google.com) is an example of Ajax. In the late 1990s, many Web sites began to want to sites began many Web In the late 1990s, beyond merely capabilities of the browser expand the as a way of HTML, and saw JavaScript presenting (DHTML) was an attempt at doing this. Dynamic HTML and CSS to produce combining HTML, JavaScript, wide adoption However, many exciting visual effects. by important differences in of DHTML was hindered at times requiring two browser implementation, to render in Netscape and completely different scripts DHTML effects sacrificed Microsoft browsers. Many in the name of “cool” usability and accessibility has been abandoned for the effects, and the language most part today. Ajax: DHTML, Take Two Ajax: DHTML, Take The Rise and Fall of Dynamic HTML and Fall of Dynamic The Rise allow them instead to focus on the end-user experience. themselves. These libraries free developers from having to spend time coding and debugging applications, and Today, many libraries of JavaScript functions exist that Today, enable developers to implement complex scripting effects while requiring that they write little or no script using the language for anything that would cause the using the language for anything that would site to break entirely in non-script environments. For example, you should never use JavaScript to completely render your navigation. of the language revolves around creating visual effects, of the language revolves around creating visual for the assistive technologies such as screen readers blind often lack the capability to correctly interpret JavaScript effects. to For these reasons, you should always be sure and avoid provide an alternative to JavaScript effects, browsers allow users to disable it. Although few users browsers allow users to disable it. Although out actually take this step, there are enough people there who sometimes or always surf the Internet with that JavaScript disabled to cause problems for sites rely on it for mission-critical site content. Disabled users often encounter problems with JavaScript as well. Given much of the implementation The biggest problem with using JavaScript is that all The biggest problem with using JavaScript entered is what is expected. JavaScript allows entered is what is expected. complicated a validation developers to write as top of the form. scheme as they need on in conjunction with CSS to JavaScript can also work effects such as drop-down achieve advanced visual menus, accordian effects, and much more. as Java or C#, JavaScript developers do not need any C#, JavaScript developers as Java or run their applications; they can additional software to instead. use any modern browser to achieve many effects JavaScript allows developers For example, HTML form not offered by HTML. limited, and offer little in the controls are extremely to ensure that the data being way of validation controls As a scripting language, JavaScript is fairly easy to language, JavaScript As a scripting languages such Unlike compiled learn and implement. JavaScript Libraries Disadvantages of JavaScript Advantages of JavaScript Advantages 04_274361-ch01.qxp 4/17/08 2:55 PM Page 9 Page PM 2:55 4/17/08 04_274361-ch01.qxp 04_274361-ch01.qxp 4/17/08 2:55 PM Page 10

Understanding Creation Tools

ecause XHTML, JavaScript, and CSS are all and SimpleText on Apple Macintosh computers are both written in plain text, you do not necessarily need basic text editors that you can use for Web pages. a specialized tool to create even the most However, an editor specifically designed for the purpose B of creating Web pages will help in many ways. complicated Web pages. Notepad on

Code Editors Code editors are applications that allow you to type your code type a few letters of the name before having the editor finish directly. Unlike simple text editors, code editors will provide it for you; it also reduces spelling errors. many tools to make design easier. • Tag completion. Editors specifically designed for Web Most code editors share common features: pages will add closing tags where needed, again saving • Line numbers. Debuggers for JavaScript and other you the time of having to type them. programming languages and validators for XHTML and Integrated reference or help functions. Most editors will CSS will all return error messages that reference line • include in their help system a complete list of elements, numbers, so having an editor that shows those numbers attributes, and a description of each. makes finding the errors easier. Color coding and syntax highlighting. Almost every editor Code hints. Many editors will display a list of available • • will color code elements and attributes in XHTML, properties elements or attributes as you type. Obviously, this saves you and rules in CSS, and language constructs in JavaScript, from having to have the exact names memorized, but it also making the code easier to read and errors easier to spot. helps in reducing your typing time as you can generally only

Eclipse set. TopStyle’s main focus is on CSS, and though it can be used to create XHTML, many developers use it solely for is very widely used open source editor. It was editing their style sheets. TopStyle is available only for originally built for Java developers, but has many plug-ins Windows. Information about TopStyle can be found at that extend its capabilities to include other languages, www.newsgator.com/Individuals/TopStyle/Default.aspx. including XHTML, CSS, and JavaScript. It can be downloaded free of charge from www.eclipse.org. Eclipse is available for both Windows and Macintosh. BBEdit A popular editor amongst Macintosh developers is BBEdit HomeSite from Bare Bones Software. It features many of the standard features of text editors, along with powerful search tools that HomeSite is a very feature-rich code editor. Given can search across documents and utilize regular expressions, Macromedia’s acquisition by Adobe, there has been little new as well as a built-in File Transfer Protocol (FTP) client. You development of the product, and Adobe has given no can purchase BBEdit at www.barebones.com. indication as to whether they will continue developing it in the future. A free 30-day trial of HomeSite is available at www.adobe.com/products/homesite. HomeSite is only TextMate available for Windows. TextMate was developed as an alternative to BBEdit for Macintosh users. It is an extremely configurable editor, TopStyle allowing users to create their syntax highlighting schemes, create macros to extend the program’s functionality, and save This editor was developed by the original creator of snippets to reuse code later. A free trial and purchase HomeSite, Nick Bradbury. It currently exists in both a information for TextMate can be found at commercial version and a free version with a smaller feature www.macromates.com.

10 Chapter 1: Introducing HTML and XHTML 11 Toolbars or panels for inserting common elements or panels for inserting Toolbars their properties and modifying simplified style sheet creation A visual CSS editor for and modification publishing tool for An integrated FTP or other uploading completed pages Powerfulmanagement features that allow for site integrated file management entering or modifying code A code view for manually if needed graphics, and InDesign, which allows designers to take graphics, and InDesign, which allows designers complex print layouts and convert them to Web-friendly the Creative layouts. While GoLive is no longer a part of Suite product line, having been replaced by with a it is still in active development, Dreamweaver, 2007. Visit new version, GoLive 9, that was released in to download a trial www.adobe.com/products/golive is available version. Like other Adobe products, GoLive in both Macintosh and Windows versions. Microsoft FrontPage by Even though it has been officially discontinued Microsoft, FrontPage remains a popular editor. creating FrontPage was originally designed to make as easy as creating documents in a word pages Web Even though it had a processor such as Microsoft Word. very simple interface and required little or no learning, it desired, and tended to lack many features professionals its reliance on creating code that would only render correctly in IE made creating cross-browser and cross- platform pages difficult. Still, its ease of use more than eyes. compensated for that in many people’s Adobe GoLive Web Before their acquisition of Macromedia, Adobe’s focus on development tool was GoLive. Its best features particular its integration with other Adobe products, in editing of Photoshop, from which it supports round-trip • • • • • A visual design view with a representation of a A visual design view with display browser’s direct competitor to Dreamweaver. It supports CSS and direct competitor to Dreamweaver. standards-based design, and also features tools that allow developers to create pages that use Microsoft’s can download a You technology. server-side ASP.NET trial of Expression from www.microsoft.com/expression/ It is only available for products/overview.aspx. Windows. Macintosh and Windows. latest entry in the visual Expression is Microsoft’s design tool market, replacing the now-discontinued is geared Expression FrontPage. Unlike its predecessor, placed as a towards professional designers and is being Adobe, and includes support for Adobe’s Ajax library, Ajax Adobe, and includes support for Adobe’s Dreamweaver also has tight integration with called Spry. of Flash other Adobe products, including easy insertion Fireworks movies and round-trip graphic editing from of can download a 30-day trial and Photoshop. You Dreamweaver from www.adobe.com/products/ for both Dreamweaver is available dreamweaver. Dreamweaver is a feature-rich, powerful design tool. Considered by many to be the industry standard designers, Dreamweaver not only amongst Web it also but supports the features mentioned previously, Web has tools for creating dynamic, database-driven is on sites with a minimal amount of code. Its focus designing standards-based XHTML pages. Dreamweaver by CS3 is the first version of the program released • Adobe Dreamweaver CS3 Features that you will find in most visual editors include: Features that you will to type little if any code. More importantly, they present the More importantly, to type little if any code. representation of the final page, designer with a visual design process. Visual editors allowing for a more natural See Is What WYSIWYG (What You are often referred to as none of them present an Get) editors, although You absolutely perfect rendering of how the page will appear in a browser. While code editors tend to give designers more direct editors tend to give designers While code editors tend to allow their code, visual design control over time: The developer has as they save for faster workflows Visual Editors Visual 04_274361-ch01.qxp 4/17/08 2:55 PM Page 11 Page PM 2:55 4/17/08 04_274361-ch01.qxp 04_274361-ch01.qxp 4/17/08 2:55 PM Page 12

Understanding Web Browsers

egardless of which tool you use to design your tool on which your users will view your page. pages, you should keep in mind that, ultimately, Unfortunately, from the early days of Web development, R you are designing for the browser. That is the browsers have posed numerous problems for designers. The Browser Wars

In 1994, Marc Andreessen and Jim Clark, both of whom had releasing a new version with new features — proprietary been working for several years on the Web in its earliest HTML elements or attributes. This was ultimately the reason implementations, founded the Netscape Corporation and behind the development of HTML 4.01, XHTML 1.0, and CSS, published Netscape Navigator, the first widely adopted Web so in the end, the Web community benefited more from the browser. Netscape Navigator quickly became the most browser wars than they were hurt by them. popular browser in the world, but in 1995 Microsoft released IE 1.0 as an add-on feature to Windows 95. The browser wars eventually ended as IE benefited from its tight integration with Windows while the operating system The two companies would fiercely compete for the browser gained dominance. In 1999, Netscape was purchased by AOL, market for the next several years in what became known as which uses the brand to this day but officially disbanded the the “browser wars.” Unfortunately, both for designers and company in 2003. HTML, the competition mostly revolved around each browser

Internet Explorer

By far the most dominant browser on the market today is aspect was the news that IE 7 would adhere much closer to Microsoft Internet Explorer, or IE. The fact that it is installed standards than past versions, and correctly implement several by default on every copy of Windows ensures that it will CSS rules that before had been either ignored by IE or continue to dominate the market for the foreseeable future. incorrectly rendered. From a Web designer’s perspective, this is both good and bad. All users of Windows Vista have IE 7 by default. At this time, The good is that if your page displays correctly on IE, you can it is the only version of IE that will work on Vista. Most be sure that in most situations the vast majority of your users Windows XP users have by now also upgraded to IE 7, will see your page as you do. The bad is that IE has long been although significant numbers still use IE 6. the least standards-compliant browser on the market, so getting your page to display correctly on it, while still For many years, Microsoft developed a version of IE for maintaining the appearance of the page on other browsers, Macintosh computers. Oddly, this version of IE often can be challenging. displayed pages differently from the Windows versions, at times being more standards-compliant, and at times less. In In 2006, Microsoft released IE 7. They introduced several new 2006, Microsoft announced the end of development of the features in this version, but for designers, the most important Mac version of IE.

Mozilla Firefox

In 1998, Netscape created the Mozilla Organization, which as a standards-compliant browser, which means that if you would continue the development of their browser as an open create your page following the rules of XHTML and CSS set source project. Mozilla is the name of the underlying forth by the W3C, your page should display correctly in rendering engine used by many browsers today, and is a Firefox. Due mostly to this, Firefox is often the primary combination of Mosaic, the name of the browser Andreessen browser on computers used by Web developers. and Clark built before founding Netscape, and Godzilla. Firefox is currently in version 2.0, and is available for Today, Mozilla supports several open source projects, the Windows, Macintosh, and most Unix machines. You can most relevant being the Firefox browser. Firefox is designed download the browser for free from www.getfirefox.com.

12 Chapter 1: Introducing HTML and XHTML 13 users your statistics for the Web as a whole are hard to come by statistics for the Web is that The good news, though, and will vary greatly. as a whole — you do not need statistics for the Web you only need to care about which browsers that you have little or no users still on old browsers, and you are free to stop worrying about them. have, and that is a statistic that is easy to come by, serverbecause your Web will have logs of that. So before you start rebuilding your page for Netscape 4.7, check your server that it will show logs. Odds are good the more standards-based browsers, such as Firefox, in the more standards-based browsers, such as to fix problems mind, and then modify your page as needed as Internet in the less standards-based browsers, such Explorer. Opera has long been standards-based, but its most recent Opera has long been standards-based, but its to see version, 9.2, features tools that allow designers what their pages may look like on very small screens, so for mobile those designers who wish to develop pages devices will often use Opera for this purpose. from Opera is available for Windows and Macintosh www.opera.com/download. For many years, the biggest challenge for the majority of for the majority the biggest challenge For many years, the fact that it was dealing with Safari was designers in in 2008 when for the Mac. This changed only available 3 for both Mac and Windows. Safari Apple released Safari from is available as a free download www.apple.com/safari/download. Netscape 4.7. These browsers offer varying levels of support for modern design principals, especially CSS, and can pose a significant challenge to designers. The obvious answer to the question about whether or not to support them is to determine if anyone is actually still accurate browser usage using them. Unfortunately, Worrying About Old Browsers A lot of clients and bosses may have read or heard something saying that their pages should be built to support older versions of browsers, particularly older versions of Internet Explorer such as 5 or 5.5, or released and it was announced that it would be free, more released and it was announced that it would people decided to take a look. The Opera browser, from Opera Software in Norway, was in Norway, from Opera Software The Opera browser, for a very long time the only browser for which you had a following Therefore, it did not develop as strong to pay. Opera 8 was as its feature set should have allowed. When challenging. Today, however, it is mostly standards however, challenging. Today, render correctly on Firefox will compliant, so pages that correctly on Safari. almost certainly render as the default browser on Mac OS X. Beginning with the browser on Mac OS as the default 10.3, Safari was bundled with the release of OS X version the release of version 10.4, it is operating system; as of the only browser included. rendering engine, on the WebKit Because Safari is based versions had some rendering rather than Mozilla, early pages for it more oddities that made designing Apple announced in 2003 that they had developed their in 2003 that they Apple announced Explorer for Macintosh to replace Internet own browser, as you can. In general, you will want to design initially with as you can. In general, you will want to design Which browser you use for general Web use is a Which browser you use for general , for Web completely personal decision. However, previously you need to have as many of the browsers listed Which Browser Should You Use? Which Browser Should You Opera Apple Safari 04_274361-ch01.qxp 4/17/08 2:55 PM Page 13 Page PM 2:55 4/17/08 04_274361-ch01.qxp 04_274361-ch01.qxp 4/17/08 2:55 PM Page 14

Understanding Web Servers

hile the browser is the palette for which you hopefully, that will be someone else’s job. However, a design your pages, Web servers play an basic understanding of servers and how they work will important role as well. As a Web designer, enable you to better appreciate their role in getting your W pages to your users. you do not need to understand servers to the point that you would feel comfortable administering a server —

The Client-Server Model HTTP

The Internet and all of its associated applications, Berners-Lee, in creating the Web, established a new including the Web, use a client-server networking protocol that would allow for the transmission of hypertext approach. Early client-server networking relied on so- documents over a TCP/IP connection. He dubbed this the called “dumb terminals” on the client side, which were Hypertext Transmission Protocol, or HTTP. While few little more than monitors connected to the network that users of the Internet have any knowledge of what it is or relied on the server to do all of their processing. Today, of why it exists, one cannot escape being aware of HTTP as course, your users will be using full-fledged computers it, of course, begins most Web addresses. that are much more powerful than the servers of old. However, these clients must still connect to a server in order to receive Web documents.

TCP/IP

Networking relies on established protocols to ensure that the computer that wishes to directly connect to the Internet needs computers on both sides of the connection are able to to have a unique IP address. Currently, the most widely communicate and exchange their data as needed. The most adopted form of IP is version 4, in which addresses are important protocols for the Internet are the Transmission expressed as four numbers between 0 and 255, separated by Control Protocol (TCP) and the Internet Protocol (IP). TCP periods or dots. IP version 4 yields just over 4 billion unique allows for the delivery of that data, while IP establishes a addresses. However, the ever-increasing popularity of the consistent addresses format that allows machines anywhere Web has created a shortage of addresses, so a new version of in the world to find one another. TCP/IP dates back to the IP, version 6, is beginning to gain use. IP version 6 uses a 1960s, and in fact the co-developers of the protocols are new address scheme that will yield a seemingly endless often referred to as the “fathers of the Internet.” Every supply of address (3.4 x 1038 total).

14 Chapter 1: Introducing HTML and XHTML 15 on which you plan to develop Web pages, you should on which you plan to develop Web mimic this functionality of the server and make sure that your pages will continue to work after you transfer them to the server. Installing a Web serverInstalling a Web opens an on your computer are obvious security hole in your machine — you running software that invites others to connect to you counteract this issue, servers are and retrieve files. To configured to retrieve documents from one specific hard drive. It can see and send folder on the machine’s files from subfolders of the root, but it cannot go is the The root above the root to any other directory. directory pages, and any in which all of your Web supporting files such as CSS documents, images, Flash movies, and anything else must be located. The server stored outside will be unable to locate any files computer When setting up your of the root directory. Root Folders patchy” server, and when it was released, Apache decided patchy” server, the serverto keep the Apache variation of that name for itself as well as the foundation. Apache lacks any user interface for Officially, text file, configuration. Instead, users must modify a settings are kept. http.config, in which all of the server’s with some This file can be daunting to the uninitiated, but fairly simple explanation and a little practice, it becomes There are several third-party to maintain the server. implementations that provide some sort of graphical interface for configuration as well. Apache Web ServerApache Web Apache IIS is the open source The main competitor for by the non-profit Apache Maintained Server. Web this lightweight serverSoftware Foundation, will run on system, including Macintosh, practically any operating OS X various Unix installations, and Windows. Macintosh ships with Apache preinstalled. engineers took When it was originally developed, software pieced them a series of existing software components and Thus, it was literally “a together to create the server. Regardless of the manufacturer, Web servers Web all do of the manufacturer, Regardless listen for requests to be the same thing. They essentially by those requests, usually and respond to made via HTTP, the user has asked for and sending it finding the document documents, the serverto them. For basic HTML will not but will instead merely send it open or read the document, off to the browser. . In these cases, the www.wiley.com is merely a piece of software that runs on a piece of software that is merely a Web server filenames that will be served Apache has by default. long set the list to index.html and index.htm, while Microsoft has always insisted on preconfiguring IIS to look for Default.htm. Most of the time, the server administrator will add index.htm and index.html to the IIS settings, as these have become well established as home pages. site’s default filenames for Web occurs when a user merely enters the domain name of a site, as typing in browser is essentially coming to the server and merely asking to connect instead of requesting a document. needs to send a document still however, The server, so every server has a setting that back to the user, allows the administrator to determine a set of special Often, users will make a request to a Web serverOften, users will make a request to a Web always without asking for a specific document. This IIS unfortunately only runs on Windows, and only on IIS unfortunately only runs on Windows, and It is the version of Windows for which is was designed. of free, and is included along with any of the versions of Windows mentioned previously with the exception include or Windows XP Home Edition, which does not support IIS. Windows XP, Windows 2003, and Windows Vista. While Windows 2003, and Windows Windows XP, the each new version has sought to improve security, basic feature set of the server has remained mostly is its unchanged. One of the nicest features of IIS graphic user interface, configuring the which makes server much easier than its competitors. Internet Information ServicesInternet Information entry serverin the Web market, Internet Microsoft’s Information Services (IIS), was introduced in 1995 on the Windows NT Server operating system. Since then, a new version of IIS with the company has released operating system, each new iteration of its server-based 2000, so today versions exist to run on Windows to the physical machine on which the Web server on which the Web to the physical machine software server to remember that a Web is running, it is important is servers many Web actually software. While exist, by far the widely used are Internet Information two most popular and Services Server and the Apache Web by Microsoft the from Apache Software Foundation. computer that is connected to the Internet and allows its is connected to the computer that use the term to refer While many people files to be shared. A Default Documents Web Servers Web 04_274361-ch01.qxp 4/17/08 2:55 PM Page 15 Page PM 2:55 4/17/08 04_274361-ch01.qxp 04_274361-ch01.qxp 4/17/08 2:55 PM Page 16

Plan Your Web Site

hen you begin work on your Web site, there Instead of this haphazard approach, you should force will be an urge to simply sit down at the yourself to sit down and carefully plan your site before computer, open up your editor, and start you ever begin typing anything. You can do this planning W on the computer or on paper — whichever is easier for creating. However, you will soon find that you start running into roadblocks, as you continually need to you. tweak your navigation, find new content, or even reach a point where you are simply unsure of what to do next.

Why Do You Want a Web Site? Where Will You Get Your Content?

The first thing to determine is exactly why you are creating Content is king on the Web. People surf the Web for a lot a Web site. What exactly do you hope your users will get of different reasons, but in the end they are all looking for out of it? With billions of sites on the Web, the odds are one thing: content. The content of your site will primarily extremely good that there are already sites out there that be the text and images on your pages. If you are building provide the same or similar information or goods or a personal site, then obviously the content will come from services that your site will. So ask yourself, why would you. Corporate sites may have a team of developers to someone want to use your site instead of someone else’s? help create the content. Content may already exist, either Occasionally, you may even talk yourself out of building in printed form, which will require that it be input into a the Web site at all if you cannot satisfactorily answer this computer, or it may already exist electronically and can question. possibly be copied and pasted from some other application. If you plan to offer multimedia on your site, you will Who Are Your Users? possibly have an even bigger hurdle to overcome, as the creation of music and video requires much more time and No traditional brick-and-mortar company would consider energy and will certainly involve other, likely expensive opening a new location without performing thorough equipment and software. Either way, you will want to have market research, and yet few Web sites do the same. You a good idea of what your content will be and where you need to know who your users are, at least in a general will get it before you start work on the site, and especially sense, before you begin any development. Are they more before you attempt to give an employer or client a likely to be young or old? How much education are they proposed deadline for completion of work on the site. likely to have? How much income? Are they likely to be computer and Web savvy or not? All of these questions should influence your approach to your pages. Computer professionals expect a much different experience when they visit a site than computer neophytes. The former group is more likely to be using higher-end hardware and software and high-speed connections, so you can feel more comfortable using multimedia on your site if that is your target. If, on the other hand, you expect a lot of users from rural areas where high-speed connections are less common and you expect your users to be much less technically inclined, then you need to adjust your site contents accordingly.

16 Chapter 1: Introducing HTML and XHTML 17 images, and if you are using multimedia, you probably images, and if you are using multimedia, you sections want a folder for that as well. If any of the main in a of the site will have multiple files, placing them subdirectory of the root will help keep you organized. that there is The most important thing to keep in mind is If you are not one “correct” way to organize the files. whatever working alone on the site, then you should use to you. If organizational scheme makes the most sense to sit down you are working in a team, then you all need and discuss how you will stay organized. Web sites modify the design to fit the desired content, not design to fit the desired sites modify the Web is by far the more around, as content the other way you be this: Would the two. Ask yourself important of an ugly site that gave you the more likely to return to or a gorgeous site that had little to information you need, of course, you will not Hopefully, offer beyond the looks? on your site, and will instead have to make this choice both functional and pretty; just have something that is should take precedence. remember that functional in the The only file that absolutely must reside directly choose to root folder is the home page. Some designers that put all of the top-level documents — the documents the root as represent the main sections of the site — in well. At the very least, you will want a folder to store your of your Web pages to fix now-broken links. of your Web hundreds of files, and larger sites can reach into the tens hundreds of files, and larger sites can reach of thousands. From the very beginning of the design of process, you should have a plan for the organization can change this organization the files on your site. You with site but unless you are using a tool later, management features such as Adobe Dreamweaver, moving a file from one directory to another late in the hundreds development process can mean having to edit all of your Web site’s assets — the HTML documents, site’s all of your Web — need to images, style sheets, multimedia, and so on be placed within a single directory on your computer as work once you develop your site, as this is how they will it is not considered a best However, on the server. It directory. practice to place all of these files loose in one many is not uncommon for even small sites to have make changes to the design as needed. Note that good make changes to the design servers, Web As was already mentioned in the section on what your site looks like is important. Most professional looks like is important. what your site many different designs before designers will sketch out they want. Some use computer they settle on the one as or Adobe graphics programs such while others simply draw Fireworks for this purpose, Once you settle on a design, rough sketches on paper. out how the content will fit and you can begin to figure While you should focus on content first and foremost, the first and foremost, focus on content While you should and a primarily visual medium, is without a doubt Web Organize Your Files Organize Your What Will the Visual Design Look Like? the Visual What Will 04_274361-ch01.qxp 4/17/08 2:55 PM Page 17 Page PM 2:55 4/17/08 04_274361-ch01.qxp