Beginning HTML, XHTML, CSS, and JavaScript

( 3 )


An indispensable introductory guide to creating web pages using the most up-to-date standards

This beginner guide shows you how to use XHTML, CSS, and JavaScript to create compelling Web sites. While learning these technologies, you will discover coding practices such as writing code that works on multiple browsers including mobile devices, how to use AJAX frameworks to add interactivity to your pages, and how to ensure your pages meet ...

See more details below
$25.51 price
(Save 27%)$34.99 List Price

Pick Up In Store

Reserve and pick up in 60 minutes at your local store

Other sellers (Paperback)
  • All (19) from $5.68   
  • New (8) from $14.99   
  • Used (11) from $5.68   


An indispensable introductory guide to creating web pages using the most up-to-date standards

This beginner guide shows you how to use XHTML, CSS, and JavaScript to create compelling Web sites. While learning these technologies, you will discover coding practices such as writing code that works on multiple browsers including mobile devices, how to use AJAX frameworks to add interactivity to your pages, and how to ensure your pages meet accessible requirements.

Packed with real-world examples, the book not only teaches you how to write Web sites using XHTML, CSS and JavaScript, but it also teaches you design principles that help you create attractive web sites and practical advice on how to make web pages more usable. In addition, special checklists and appendices review key topics and provide helpful references that re-enforce the basics you've learned.

  • Serves as an ideal beginners guide to writing web pages using XHTML
  • Explains how to use CSS to make pages more appealing and add interactivity to pages using JavaScript and AJAX frameworks
  • Share advice on design principles and how to make pages more attractive and offers practical help with usability and accessibility
  • Features checklists and appendices that review key topics

This introductory guide is essential reading for getting started with using XHTML, CSS and JavaScript to create exciting and compelling Web sites.

Note: CD-ROM/DVD and other supplementary materials are not included as part of eBook file.

Read More Show Less

Product Details

  • ISBN-13: 9780470540701
  • Publisher: Wiley
  • Publication date: 12/30/2009
  • Edition number: 1
  • Pages: 864
  • Sales rank: 579,168
  • Product dimensions: 7.40 (w) x 9.20 (h) x 1.80 (d)

Meet the Author

Jon Duckett has spent over a decade helping a wide range of companies implement innovative web strategies. Taking a hands-on approach, he designs many of the projects he works on and helps to code them. During this time, Jon has written several books covering web design, programming, accessibility and usability.

Read More Show Less

Read an Excerpt

Beginning HTML, XHTML, CSS, and JavaScript

By Jon Duckett

John Wiley & Sons

Copyright © 2010 John Wiley & Sons, Ltd
All right reserved.

ISBN: 978-0-470-54070-1

Chapter One

Structuring Documents for the Web

In this chapter, you learn the key concept of creating any web page: how to give it structure. You need to add structure to a document so that web browsers can present the page to people who visit your site in a way they will understand. For example, imagine a news article that contains a headline (or title) and several paragraphs of text; if you wanted to put this article on the Web, you would need to add structure to the words in the document so that the browser knows which words are the headline, and where each paragraph starts and ends. To give a document structure, you'll need to learn how to create web pages using HTML. Or, to be a little more precise, this book focuses on a type of HTML known as XHTML.

In this chapter you will:

Create several example web pages in XHTML.

See how a web page describes its structure to a web browser.

Discover the meaning of some key terms used by web designers, such as elements, attributes, tags, and markup.

By the end of the chapter, you will have learned the basic building blocks needed to build a web page, and will have put thisinto practice with several examples.

A Web of Structured Documents

Before we create our first web page, let's just take a moment to look at the printed information we see every day, and how it compares to what we see on the Web. Every day, you come across all kinds of printed documents - newspapers, train timetables, insurance forms. You can think of the Web as being a sea of documents that all link together, and bear a strong similarity to the printed documents that you meet in everyday life.

Every morning I used to read a newspaper. A newspaper is made up of several stories or articles (and probably a fair smattering of advertisements, too). Each story has a headline and then some paragraphs, perhaps a subheading, and then some more paragraphs; it may also include a picture or two.

I don't buy a daily paper anymore, as I tend to look at news online, but the structure of articles on news web sites is very similar to the structure of articles in newspapers. Each article is made up of headings, paragraphs of text, and some pictures (sometimes the pictures might be replaced by a video). The parallel is quite clear; the only real difference is that in a newspaper you may have several stories on a single page, whereas on the Web each story tends to get its own page. The news web sites also often use homepages that display the headline and a brief summary of the stories.

Consider another example: Say I'm catching a train to see a friend, so I check the schedule or timetable to see what time the trains go that way. The main part of the schedule is a table telling me what times trains arrive and when they depart from different stations. You can probably think of several types of documents that use tables. From the listings in the financial supplement of your paper to the TV schedule, you come across tables of information every day - and often when this information is put on the Web, these tables are recreated.

Another common type of printed document is a form. For example, on my desk at the moment, I have a form (which I really must mail) from an insurance company. This form contains fields for me to write my name, address, and the amount of coverage I want, along with checkboxes to indicate the number of rooms in the house and what type of lock I have on my front door. There are lots of forms on the Web, from simple search boxes that ask what you are looking for to the registration forms you are required to go through before you can place an online order for books or CDs.

As you can see, there are many parallels between the structure of printed documents you come across every day and pages you see on the Web. When it comes to writing web pages, it is the XHTML code you start learning in this chapter that tells the web browser how the information you want to display is structured - what text to put in a heading, or in a paragraph, or in a table, and so on - so that the browser can present it properly to the user.

Introducing HTML and XHTML

Even if you have never seen any HTML (Hypertext Markup Language) code, you may be familiar with the fact that it is used to create most web pages. There have been several versions of HTML since the Web began, and the development of the language is overseen by an organization called the W3C (World Wide Web Consortium).

The last major version of HTML was HTML 4.01 in December 1999. In January 2000, some stricter rules were added to HTML 4.01, creating what is known as XHTML (Extensible Hypertext Markup Language), and it is this version of the language that we will be focusing on throughout this book. Generally, you will see the term XHTML used in the rest of this book. Unless otherwise mentioned, the same rules apply to HTML.

I use this stricter XHTML syntax because it can be processed by more applications than HTML 4.01. If you are interested, there is a summary of the differences between HTML 4 and XHTML 1.0 in Chapter 14. There is also a brief look forward to what will be the next version of HTML, HTML 5, in another section of Chapter 14.

As its name suggests, XHTML is a markup language, which may sound complicated, until you realize that you come across markup every day. When creating a document in a word processor, you can add styles to the text to explain the document's structure. For example, you can distinguish headings from the main body of the text using a heading style (usually with a larger font). You can use the Return (or Enter) key to start a new paragraph. You can insert tables into your document to hold data, or create bulleted lists for a series of related points, and so on. While this does affect the presentation of the document, the key purpose of this kind of markup is to provide a structure that makes the document easier to understand.

When marking up documents for the Web, you are performing a very similar process, except you do it by adding things called tags to the text. With XHTML, the key thing to remember is that you are adding the tags to indicate the structure of the document (not how you want it to be presented); for example, which part of the document is a heading, which parts are paragraphs, what belongs in a table, and so on. Browsers such as Internet Explorer, Firefox, and Safari all use this markup to help present the text in a familiar fashion, similar to that of a word processor - main headings are bigger than the text in paragraphs, there is space above and below each paragraph, lists of bullet points have a circle in front of them. But the XHTML specification does not specify which font should be used or what size that font should be.

While earlier versions of HTML allowed you to control the presentation of a document - such as which typefaces and colors a document should use - XHTML markup is not supposed to be used to style the document; that is the job of CSS, which you meet in Chapter 7.

Let's have a look at a very simple web page. As I mentioned in the Introduction, you don't need any special programs to write web pages - you can simply use a text editor such as Notepad on Windows or TextEdit on a Mac, and save your files with the .html file extension. You can download this example along with all the code for this book from the Wrox web site at; the example is in the Chapter 1 folder (along with other examples from this chapter) and is called ch01_eg01.html.

<html> <head> <title>Popular Websites: Google</title> </head> <body> <H1>About Google</H1>

Google is best known for its search engine, although Google now offers a number of other services.

Google's mission is to organize the world's information and make it universally accessible and useful.

Its founders Larry Page and Sergey Brin started Google at Stanford University.

</body> </html>

This may look a bit confusing at first, but it will all make sense soon. As you can see, there are several sets of angle brackets with words or letters between them, such as <html>, <head>, </title>, and </body>. These angle brackets and the words inside them are known as tags, and these are the markup I have been talking about. Figure 1-1 illustrates what this page would look like in a web browser.

As you can see, this document contains the heading "About Google" and a paragraph of text to introduce the company. Note also that it says "Popular Websites: Google" in the very top-left of the browser window; this is known as the title of the page (to the right it says Mozilla Firefox, which is the browser this page was opened in).

To understand the markup in this first example, you need to look at what is written between the angle brackets and compare that with what you see in the figure, which is what you will do next.

Tags and Elements

If you look at the first and last lines of the code for the last example, you will see pairs of angle brackets containing the letters "html" Starting on the first line, the first angled bracket looks like a less-than sign, then there are the letters "html," followed by a second angled bracket, which looks like a greater-than sign. The two brackets and all of the characters between them are known as a tag.

In this example, there are lots of tags and they are all in pairs; there are opening tags and closing tags. The closing tag is always slightly different from the opening tag in that it has a forward slash after the first angled bracket: </html>.

A pair of tags and the content these include are known as an element. In Figure 1-2, you can see the heading for the page of the last example.

The opening tag says "This is the beginning of a heading" and the closing tag says "This is the end of a heading." Like most tags in XHTML, the text inside the angled brackets explains the purpose of the tag - here h1 indicates that it is a level 1 heading (or top-level heading). As you will see shortly, there are also tags for subheadings (<H2>, <H3>, <H4>, <H5>, and <H6>). If we had not put tags around the words "About Google," it would just be another bit of text; it would not be clear that these words formed the heading.

Now look at the three paragraphs of text about the company; each one is placed between an opening <p> tag and a closing </p> tag. And, you guessed it, the p stands for paragraph.

As you can see, the tags throughout this example actually describe what you will find between them, creating the structure of the document. The text between the <H1> and </H1> tags is a heading, and between the opening <p> and closing </p> tags make up paragraphs. Indeed, the whole document is contained between opening <html> and closing </html> tags.

You will often find that terms from a family tree are used to describe the relationships between elements. For example, an element that contains another element is known as the parent, while the element that's between the parent element's opening and closing tags is called a child of that element. So, the <title> element is a child of the <head> element, the <head> element is the parent of the <title> element, and so on. Furthermore, the <title> element can be thought of as a grandchild of the <html> element.

It is worth noting that the tags in this example are all in lowercase characters; you will sometimes see web pages written in HTML where tags are uppercase (or a mix of uppercase and lowercase letters). When XHTML was introduced, with its stricter rules, it stated that all tags were written in lowercase.

Separating Heads from Bodies

Whenever you write a web page in XHTML, the whole of the page is contained between the opening <html> and closing </html> tags, just as it was in the last example. Inside the <html> element, there are two main parts to the page:

The <head> element: Often referred to as the head of the page, this contains information about the page (this is not the main content of the page). For example, it might contain a title and a description of the page, or instructions on where a browser can find CSS rules that explain how the document should look. It consists of the opening <head> tag, the closing </head> tag, and everything in between.

The <body> element: Often referred to as the body of the page, this contains the information you actually see in the main browser window. It consists of the opening <body> tag, closing </body> tag, and everything in between.

Together, the <html>, <head>, and <body> elements make up the skeleton of an XHTML document - they are the foundation upon which every web page is built.

Inside the <head> element of the first example page, you can see a <title> element:

<head> <title>Popular Websites: Google</title> </head>

Between the opening <title> tag and the closing </title> tag are the words Popular Websites: Google, which is the title of this web page. When I introduced Figure 1-1, which showed the screenshot of this page, I called your attention to the words right at the top of the browser window. This is where browsers such as Internet Explorer, Firefox, and Safari display the title of a document; it is also the name they use when you save a page in your favorites, and it helps search engines understand what your page is about.

The real content of your page is held in the <body> element, which is what you want users to read, and this is shown in the main browser window.

You may have noticed that the tags in this example appear in a symmetrical order. If you want to have one element inside another, then both the element's opening and closing tags must be inside the containing element. For example, the following is allowed:

<p> This paragraph contains some <em>emphasized text.</em></p>

whereas the following is wrong because the closing </em> tag is not inside the paragraph element:

<p> This paragraph contains some <em>emphasized text. </p></em>

In other words, if an element is to contain another element, it must wholly contain that element. This is referred to as nesting your elements correctly.

Attributes Tell Us About Elements

What really differentiates web documents from standard documents are the links (or hyperlinks) that take you from one web page to another. Let's take a look at a link by adding one to the example you just looked at. Links are created using an <a> element (the a stands for anchor).

Here we will add a link from this page to Google in a new paragraph at the end of the document. There is just one new line in this example (code sample ch01_eg02.html) and that line is highlighted:

<title>Popular Websites: Google</title>
<H1>About Google</H1>

Google is best known for its search engine, although Google now offers a number of other services.

Google's mission is to organize the world's information and make it universally accessible and useful.

Its founders Larry Page and Sergey Brin started Google at Stanford University.

<a href="">Click here to visit Google's Web site.</a>


Inside this new paragraph is the <a> element that creates the link. Between the opening <a> tag and the closing </a> tag is the text that you can click on, which says "Click here to visit Google's Web site." Figure 1-3 shows you what this page looks like in a browser.

If you look closely at the opening tag of the link, it carries something called an attribute. In this case, it's the href attribute; this is followed by an equal sign, and then a pair of quotation marks which contain the URL for Google's web site. In this case, the href attribute is telling you where the link should take you. You'll look at links in greater detail in the next chapter, but for the moment this illustrates the purpose of attributes.


Excerpted from Beginning HTML, XHTML, CSS, and JavaScript by Jon Duckett Copyright © 2010 by John Wiley & Sons, Ltd. Excerpted by permission.
All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.

Read More Show Less

Table of Contents

Introduction xxi

Chapter 1: Structuring Documents for the Web 1

A Web of Structured Documents 1

Introducing HTML and XHTML 2

Basic Text Formatting 10

Presentational Elements 19

Phrase Elements 23

Lists 30

Editing Text 38

Using Character Entities for Special Characters 39

Comments 40


Element (Deprecated) 40

Understanding Block and Inline Elements 41

Grouping Elements with
and 42

Core Elements and Attributes 45

Attribute Groups 47

Summary 51

Exercises 52

Chapter 2: Links and Navigation 55

Basic Links 55

Understanding Directories and Directory Structures 61

Understanding URLs 62

Creating Links with the Element 66

Advanced E-mail Links 76

Summary 78

Exercises 78

Chapter 3: Images, Audio, and Video 79

Adding Images Using the Element 79

Using Images as Links 88

Image Maps 89

Choosing the Right Image Format 95

Adding Flash, Video, and Audio to Your Web Pages 104

Summary 127

Exercises 128

Chapter 4: Tables 131

Introducing Tables 131

Basic Table Elements and Attributes 139

Adding a

Grouping Sections of a Table 151

Nested Tables 158

Accessible Tables 160

Summary 164

Exercises 165

Chapter 5: Forms 167

Introducing Forms 168

Creating a Form with the <form> Element 171

Form Controls 175

Creating Labels for Controls and the Element 198

Structuring Your Forms with <fieldset> and <legend> Elements 200

Focus 202

Disabled and Read-Only Controls 205

Sending Form Data to the Server 207

Summary 211

Exercises 212

Chapter 6: Frames 215

Introducing the Frameset 216

When To Use Frames 218

The <frameset> Element 219

The <frame> Element 225

The <noframes> Element 228

Creating Links Between Frames 228

Setting a Default Target Frame Using the <base> Element 230

Nested Framesets 231

Inline or Floating Frames with <iframe> 234

Summary 240

Exercises 240

Chapter 7: Cascading Style Sheets 243

Introducing CSS 244

Where You Can Add CSS Rules 250

CSS Properties 254

Controlling Text 255

Text Formatting 264

Text Pseudo-Classes 273

Selectors 276

Lengths 283

Introducing the Box Model 285

Summary 304

Exercises 304

Chapter 8: More Cascading Style Sheets 307

Links 308

Backgrounds 309

Lists 317

Tables 320

Outlines 328

The :focus and :active Pseudo-Classes 330

Generated Content 331

Miscellaneous Properties 335

Additional Rules 338

Positioning and Layout with CSS 340

Summary 355

Exercises 355

Chapter 9: Page Layout 357

Understanding the Site’s Audience 358

Page Size (and Screen Resolution) 365

Designing Pages 373

Coding Your Design 391

Developing for Mobile Devices 408

Summary 419

Exercises 419

Chapter 10: Design Issues 421

Typography 422

Navigation 440

Tables 454

Forms 456

Summary 479

Exercises 479

Chapter 11: Learning JavaScript 481

What Is Programming About? 482

How to Add a Script to Your Pages 484

The Document Object Model 488

Starting to Program with JavaScript 501

Variables 502

Operators 503

Functions 506

Conditional Statements 508

Looping 511

Events 514

Built-in Objects 516

Writing JavaScript 528

Summary 530

Exercises 531

Chapter 12: Working with JavaScript 533

Practical Tips for Writing Scripts 533

Form Validation 535

Form Enhancements 556

JavaScript Libraries 570

Summary 584

Exercises 585

Chapter 13: Putting Your Site on the Web 587

Meta Tags 588

Testing Your Site 593

Taking the Leap to Live 601

Telling the World about Your Site 607

Understanding Your Visitors 613

What Next? 616

Summary 626

Chapter 14: Checklists 627

Search Engine Optimization Checklist 627

Accessibility Checklist 631

Differences Between HTML and XHTML 635

HTML 5 637

Appendix A: Answers to Exercises 641

Appendix B: XHTML Element Reference 677

Appendix C: CSS Properties 713

Appendix D: Color Names and Values 741

Appendix E: Character Encodings 749

Appendix F: Special Characters 753

Appendix G: Language Codes 767

Appendix H: MIME Media Types 771

Appendix I: Deprecated and Browser - Specific Markup 783

Index 815

to a Table 151
Read More Show Less

Customer Reviews

Average Rating 4.5
( 3 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 3 Customer Reviews
  • Posted March 13, 2010

    Excellent learning tool and reference

    From the point of a beginner where it comes to website coding, I find Mr. Jon Duckett's knowledge and understanding of HTML, XHTML and Java Script to be backup by obvious experience and an eagerness to share his knowledge in a concise and very readable manner.

    Before purchasing this book, I browsed through many other books on the same subjects and found Mr. Duckett's to be the one that connected in the manner that was important to me. There is a lot of information that is between the covers of this book; however, the ability to go over complex material and to have it on hand as future reference makes this book a winner from my viewpoint. A good teacher is not made by having all the knowledge in the world if the person is incapable to relating that knowledge on a level that is comprehensive as well as interesting to all students at every level of aptitude. This is not an easy undertaking, for either the teacher loses some by going over their heads or others by boring them with no challenge.

    Mr. Duckett successfully covers and completes his objectives in publishing this book, and I do not hesitate recommending it for those attempting to understand the complexity of web design and the coding it takes to produce a good web page.

    3 out of 3 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted July 25, 2011

    No text was provided for this review.

  • Anonymous

    Posted December 26, 2010

    No text was provided for this review.

Sort by: Showing all of 3 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)