HTML5 Pocket Reference
Jennifer Niederst Robbins
Beijing Cambridge Farnham Kln Sebastopol Tokyo
Download from Wow! eBook
Special Upgrade Offer
If you purchased this ebook directly from oreilly.com, you have the following benefits:
DRM-free ebooksuse your ebooks across devices without restrictions or limitations
Multiple formatsuse on your laptop, tablet, or phone
Lifetime access, with free updates
Dropbox syncingyour files, anywhere
If you purchased this ebook from another retailer, you can upgrade your ebook to take advantage of all these benefits for just $4.99. to access your ebook upgrade.
Please note that upgrade offers are not available from sample content.
Chapter 1. HTML5 Pocket Reference
HTML ( HyperText Markup Language ) is the markup language used to turn text documents into web pages and applications. The fundamental purpose of HTML as a markup language is to provide a semantic description (the meaning) of the content and establish a document structure (a hierarchy of elements).
This pocket reference provides a concise yet thorough listing of the elements and attributes specified in the HTML5 Candidate Recommendation maintained by the World Wide Web Consortium (W3C) dated December 17, 2012, the HTML 5.1 Editors Draft dated June 15, 2013, and the living HTML specification maintained by the Web Hypertext Application Technology Working Group (WHATWG) as of June 15, 2013.
Elements and attributes from the HTML 4.01 Specification that were made obsolete in HTML5 have been omitted from this edition. The elements and attributes contained in this book may be used in HTML 4.01, XHTML 1.0, or XHTML 1.1 documents, unless they are explicitly marked Not in HTML 4.01, in which case they will cause the document to be invalid.
HTML5 documents can be written in XHTML syntax (formally known as the XML Serialization of HTML5), so whenever applicable, special considerations for XHTML will be noted. See at the end of this reference for details on XHTML syntax requirements.
This book is organized into the following sections:
HTML5 Overview
HTML5 offers new features (elements, attributes, event handlers, and APIs) for easier web application development and more sophisticated form handling.
The HTML5 specification is based on HTML 4.01 Strict, but unlike previous HTML Recommendations, HTML5 does not use a Document Type Definition (DTD). Instead, it uses the Document Object Model (DOM, the tree formed by a documents structure) as its basis rather than a particular set of syntax rules. It also differs from previous recommendations in that it includes detailed instructions for how browsers should handle malformed and legacy markup.
W3C and WHATWG
There are two organizations maintaining slightly different HTML specifications as of this writing.
HTML5 was originally written by the Web Hypertext Application Technology Working Group (WHATWG). In 2003, members of Apple, Mozilla, and Opera formed the WHATWG to further the development of HTML in a way that was consistent with real-world authoring practices and browser behavior. Their initial documents, Web Applications 1.0 and Web Forms 1.0, were rolled together into HTML5, which is still in development under the guidance of WHATWG editor, Ian Hickson. They eventually dropped the version number and now maintain living (unnumbered) HTML specification at whatwg.org .
In 2006, the World Wide Web Consortium (W3C) formed its own HTML5 Working Group based on the work by the WHATWG. In 2009, it discontinued its work on XHTML 2.0 in order to focus on the development of HTML5. The W3C maintains a snapshot (numbered) version of HTML5 ( www.w3.org/TR/html5/ ), which is expected to reach Recommendation status in 2014. HTML5.1 is also in development and is scheduled to become a Recommendation in 2016. Nightly builds of the HTML5.1 Editors Draft are available at www.w3.org/html/wg/drafts/html/master/ .
The differences between the W3C and HTML5 Candidate Recommendation and the WHATWG versions are fairly minor. The WHATWG and HTML5.1 spec change frequently, but the differences as of this writing include:
WHATWG only
ping attribute on a and area elements |
srcset attribute on img element |
WHATWG and W3C HTML5.1 only
data element |
menuitem element |
dialog element |
main element |
inert global attribute |
itemid , itemprop , itemref , itemscope , and itemtype global attributes |
onclose and onsort global event handlers |
download attribute on a and area elements |
sortable attribute on table element |
sorted attribute on th element |
W3C HTML5 only
command element (replaced by menuitem ) |
media attribute on a element |
pubdate attribute on time element |
New Semantic Elements in HTML5
HTML5 includes :
article | figcaption | output |
aside | figure | progress |
audio | footer | rp |
bdi | header | rt |
canvas | hgroup * | ruby |
command * | keygen | section |
data ** | main ** | source |
datalist | mark | time |
details | menuitem ** | track |
dialog ** | meter | video |
embed | nav | wbr |
* Removed from HTML5.1
** WHATWG and HTML5.1 only
New input types
HTML5 introduces the following new input control types (indicated as values for the type
attribute for the input
element): color
, date
, datetime
, datetime-local
, email
, month
, number
, range
, search
, tel
, time
, url
, and week
.
Obsolete HTML 4.01 elements
The following HTML 4.01 elements were made obsolete in HTML5 because they were presentational, confusing, or poorly supported: acronym
, applet
, basefont
, big
, center
, dir
, frame
, frameset
, font