HTML5 Guidelines for Web Developers

(coco) #1

12 Chapter 1—Overview of the New Web Standard


The manifest attribute of the html element seems inconspicuous but has far-
reaching consequences: It paves the way for offline web applications by referring
to the configuration file determining which parts of the page should be made
available offline. The style elements with the attribute scoped can also be useful,
limiting the validity of the specified styles to the area of the superordinate DOM
node and all its child elements. For menu elements, type and label determine the
type of menu (for example, context menu or toolbar), plus its label.
Small but sweet improvements include using the charset attribute in the meta
tag to simplify specifying the encoding; having the option of using li elements
via value to assign explicit list values; specifying a starting point for ol with start;
and finally being able to sort lists in reverse order with reversed.
Some of the global attributes that are valid for all elements have been changed
significantly. This does not apply so much to class, dir, id, lang, style, tab-
index, and title, which are now global in contrast to HTML4, but mainly to the
new attributes that have been added. With contenteditable you can now edit
elements directly; contextmenu enables assigning your own menus, defined as
menu; draggable marks the relevant element as a potential candidate for drag-
and-drop actions; and spellcheck prepares for checking the relevant section for
spelling errors.
Contents that are not or no longer relevant at the time of display can be hid-
den; the attribute role or aria-* can be used to offer additional help for assistive
technologies, such as Screenreader; and the reserved prefix data-* enables you
to define as many of your own attributes as you like.
Another important part of HTML5 is that of new programming APIs, for exam-
ple, the canvas element API, an API for playing audio and video contents, and an
interface for programming offline web applications. Further APIs are devoted to
the topics drag-and-drop, editing documents, or governing the browser history.
The specification even contains some initially exotic-seeming APIs for register-
ing and applying your own protocols or MIME types.
We should also mention that in HTML5 all event handlers are global attributes
and that certain changes were made to the objects HTMLDocument and HTMLEle-
ment. With getElementsByClassName(), you can find all elements with a particular
class attribute; you can manipulate class attributes with the classList API; and
you can now use the method innerHTML with XML documents, too. You can de-
termine which element in the document is currently in focus with activeElement
and hasFocus—both as attributes of the HTMLDocument object, just as with the
method getSelection(), which returns the text currently selected by the user.
Free download pdf