HTML5: Up and Running (Paperback)

Mark Pilgrim

  • 出版商: O'Reilly
  • 出版日期: 2010-09-21
  • 定價: $990
  • 售價: 3.0$299
  • 語言: 英文
  • 頁數: 222
  • 裝訂: Paperback
  • ISBN: 0596806027
  • ISBN-13: 9780596806026
  • 相關分類: HTML
  • 立即出貨 (庫存 < 3)




If you don't know about the new features available in HTML5, now's the time to find out. The latest version of this markup language is going to significantly change the way you develop web applications, and this book provides your first real look at HTML5's new elements and attributes.

Even though work on HTML5 is ongoing, browsers such as Safari, Mozilla, Opera, and Chrome already support many of its features -- and browsers for smart phones are even farther ahead, especially iPhone's MobileSafari browser. With HTML5: Up & Running, you'll learn how this new version enables browsers to interact with JavaScript much more easily than before. You'll also learn how HTML5 can help you develop applications that:

  • Display video directly in the browser, without having to rely on plugins
  • Work even when a user is offline, by taking advantage of HTML5's persistent storage
  • Offer a drawing canvas for dynamically generated 2-D graphics

This concise guide is the most complete and authoritative book you'll find on the subject. Author Mark Pilgrim writes the weekly digest for the HTML5 Working Group, and represents Google at conferences on HTML5's capabilities. Stay ahead of the curve. Order a copy of this book today.

Five Things You Should Know About HTML5
by Mark Pilgrim

1. It’s not one big thing. You may well ask: “How can I start using HTML5 if older browsers don’t support it?” But the question itself is misleading. HTML5 is not one big thing; it is a collection of individual features. So you can’t detect “HTML5 support,” because that doesn’t make any sense. But you can detect support for individual features, like canvas, video, or geolocation.

You may think of HTML as tags and angle brackets. That’s an important part of it, but it’s not the whole story. The HTML5 specification also defines how those angle brackets interact with JavaScript, through the Document Object Model (DOM). HTML5 doesn’t just define video tag; there is also a corresponding DOM API for video objects in the DOM. You can use this API to detect support for different video formats, play a video, pause, mute audio, track how much of the video has been downloaded, and everything else you need to build a rich user experience around the video tag itself.

Chapter 2 and Appendix A will teach you how to properly detect support for each new HTML5 feature.

2. You don’t need to throw anything away. Love it or hate it, you can’t deny that HTML 4 is the most successful markup format ever. HTML5 builds on that success. You don’t need to throw away your existing markup. You don’t need to relearn things you already know. If your web application worked yesterday in HTML 4, it will still work today in HTML5. Period.

Now, if you want to improve your web applications, you’ve come to the right place. Here’s a concrete example: HTML5 supports all the form controls from HTML 4, but it also includes new input controls. Some of these are long-overdue additions like sliders and date pickers; others are more subtle. For example, the email input type looks just like a text box, but mobile browsers will customize their onscreen keyboard to make it easier to type email addresses. Older browsers that don’t support the email input type will treat it as a regular text field, and the form still works with no markup changes or scripting hacks. This means you can start improving your web forms today, even if some of your visitors are stuck on IE 6.

Read all the gory details about HTML5 forms in Chapter 9.

3. It’s easy to get started. “Upgrading” to HTML5 can be as simple as changing your doctype. The doctype should already be on the first line of every HTML page. Previous versions of HTML defined a lot of doctypes, and choosing the right one could be tricky. In HTML5, there is only one doctype: !DOCTYPE html

Upgrading to the HTML5 doctype won’t break your existing markup, because all the tags defined in HTML 4 are still supported in HTML5. But it will allow you to use -- and validate -- new semantic elements like article, section, header, and footer. You’ll learn all about these new elements in Chapter 3.

4. It already works Whether you want to draw on a canvas, play video, design better forms, or build web applications that work offline, you’ll find that HTML5 is already well-supported. Firefox, Safari, Chrome, Opera, and mobile browsers already support canvas (Chapter 4), video (Chapter 5), geolocation (Chapter 6), local storage (Chapter 7), and more. Google already supports microdata annotations (Chapter 10). Even Microsoft -- rarely known for blazing the trail of standards support -- will be supporting most HTML5 features in the upcoming Internet Explorer 9.

Each chapter of this book includes the all-too-familiar browser compatibility charts. But more importantly, each chapter includes a frank discussion of your options if you need to support older browsers. HTML5 features like geolocation (Chapter 6) and video (Chapter 5) were first provided by browser plugins like Gears or Flash. Other features, like canvas (Chapter 4), can be emulated entirely in JavaScript. This book will teach you how to target the native features of modern browsers, without leaving older browsers behind.

5. It’s here to stay. Tim Berners-Lee invented the world wide web in the early 1990s. He later founded the W3C to act as a steward of web standards, which the organization has done for more than 15 years. Here is what the W3C had to say about the future of web standards, in July 2009:
    Today the Director announces that when the XHTML 2 Working Group charter expires as scheduled at the end of 2009, the charter will not be renewed. By doing so, and by increasing resources in the HTML Working Group, W3C hopes to accelerate the progress of HTML5 and clarify W3C’s position regarding the future of HTML.
HTML5 is here to stay. Let’s dive in.



儘管HTML5的工作仍在進行中,但Safari、Mozilla、Opera和Chrome等瀏覽器已經支持其中的許多功能,而智能手機的瀏覽器則更加先進,尤其是iPhone的MobileSafari瀏覽器。通過《HTML5: Up & Running》,你將學習到這個新版本如何使瀏覽器與JavaScript的交互比以前更加容易。你還將學習到HTML5如何幫助你開發以下應用程序:

- 在瀏覽器中直接顯示視頻,無需依賴插件
- 在用戶離線時仍然工作,利用HTML5的持久存儲功能
- 提供一個繪圖畫布,用於動態生成的2D圖形

這本簡明指南是你在這個主題上能找到的最完整和權威的書籍。作者Mark Pilgrim是HTML5工作組的每週摘要作者,並代表Google在HTML5能力的會議上發言。保持領先。立即訂購這本書的副本。

作者:Mark Pilgrim

1. 它不是一個大東西。你可能會問:“如果舊的瀏覽器不支持HTML5,我怎麼開始使用它?”但這個問題本身是誤導的。HTML5不是一個大東西,它是一系列個別的功能。所以你無法檢測“HTML5支持”,因為這沒有任何意義。但你可以檢測對個別功能的支持,比如canvas、視頻或地理位置。

你可能認為HTML只是標籤和尖括號。這是其中的一個重要部分,但不是全部。HTML5規範還定義了尖括號如何通過文檔對象模型(DOM)與JavaScript交互。HTML5不僅定義了視頻標籤,還有對應的DOM API,用於處理DOM中的視頻對象。你可以使用這個API來檢測對不同視頻格式的支持,播放視頻,暫停,靜音音頻,追踪已下載的視頻量,以及其他一切你需要在視頻標籤周圍建立豐富用戶體驗的功能。


2. 你不需要丟棄任何東西。無論你喜歡還是討厭,你都不能否認HTML 4是最成功的標記格式。HTML5建立在這一成功的基礎上。你不需要丟棄你現有的標記。你不需要重新學習你已經知道的東西。如果你的網絡應用程序在HTML 4中昨天工作,它在HTML5中今天仍然可以工作。沒有例外。

現在,如果你想改進你的網絡應用程序,你來對地方了。這裡有一個具體的例子:HTML5支持HTML 4中的所有表單控件,但它還包括新的輸入控件。其中一些是早就應該添加的,比如滑塊和日期選擇器;其他一些則更加微妙。例如,電子郵件輸入類型看起來就像一個文本框,但移動瀏覽器將自定義其屏幕鍵盤,以便更容易輸入電子郵件地址。不支持電子郵件輸入類型的舊瀏覽器將將其視為常規文本字段。