HTML and CSS Reference
In-Depth Information
What is an HTML5 API?
The HTML5 spec is ground-breaking in many ways, but one of the key ways is
that it specifies both the syntax of the HTML markup and the APIs you should
use to manipulate the document with JavaScript. Earlier specs kept those sepa-
rate: the Web Hypertext Application Technology Working Group (WHATWG) felt
this was both a source of needless duplication and a recipe for inconsistency.
You've already seen several of HTML5's APIs in action—the form-validation API
in chapter 2, the canvas in chapter 3, and the video and audio APIs in the last
chapter—but there are many more.
The WHATWG produced a very long HTML spec that splits into 11 standards at
the W3C, one of which is the HTML5 spec. In addition, several other specs, such
as the Geolocation API, have never been part of the WHATWG spec but are con-
sidered part of the HTML5 buzzword nevertheless. In this topic, we'll follow the
more liberal definition because that lets you play with more fun stuff!
First, let's look at one of the APIs that's part of the core HTML5
specification: contentEditable . It allows ricH text editing in the
browser-a What—You See Is What You Get (WYSIWYG) environment similar
to the experience people are used to with modern word processors.
Rich-text editing with the contenteditable attribute
The web was originally intended to be a place where people would cre-
ate and share documents. But web browsers are complex to implement
on their own, and existing text editors were good enough for creating
web documents, so the creation and viewing of web content has histor-
ically been kept separate. Various solutions have arisen that enable the
Search WWH ::

Custom Search