This Week in HTML5 – Episode 36
Since I started publishing these weekly summaries over a year ago, I've watched the HTML5 specification grow up. In episode 1, the big news of the week was the birth of an entirely new specification (Web Workers). Slowly, steadily, and sometimes painstakingly, the HTML5 specification has matured to the point where the hottest topic last week was the removal of a little-used element (<dialog>
) and the struggle to find a suitable replacement for marking up conversations.
This week's changes are mundane, and I expect (and hope!) that future summaries will be even more mundane. That's a good thing; it tells me that, as implementors continue implementing and authors continue authoring, there are no show-stoppers and fewer and fewer "gotchas" to trip them up. Thus, the overarching theme this week -- and I use the term "theme" very loosely -- is "the never-ending struggle to get the details right."
Parsing
HTML5 is full of algorithms. Most of them are small parts of one mega-algorithm, called Parsing HTML Documents. Contrary to popular belief, the HTML parsing algorithm is deterministic: for any sequence of bytes, there is one (and only one) "correct" way to interpret it as HTML. Notice I said "any sequence of bytes," not just "any sequence of bytes that conforms to a specific DTD or schema." This is intentional; HTML5 not only defines what constitutes "valid" HTML markup (for the benefit of conformance checkers), it also defines how to parse "invalid" markup (for the benefit of browsers and other HTML consumers that take existing web content as input). And sweet honey on a stick, there sure is a lot of invalid markup out there.
- r3896 tells parsers to ignore almost any end tags before the
<html>
tags. There are a few special end tags which cause the parser to start constructing a new document:</html>
,</head>
,</body>
, and oddly enough,</br>
. [Related: Bug 7672] - r3909 clarifies how user agents should parse the
type
attribute of a<script>
tag. Thetype
attribute is optional; authors can simply omit it if they're embedding JavaScript. - r3923 tweaks the algorithm for parsing the
DOCTYPE
declaration. This affectsDOCTYPE
sniffing. - r3967 clarifies the algorithm for ignoring the first newline or carriage return character at the beginning of a
<pre>
block. [Background: [whatwg] Initial carriage return in<pre>
and<textarea>
] - r3968 explains why the
<embed>
element can have an infinite number of attributes. (Answer: because they are passed directly to the third-party plugin that handles the embedded content, and there are no restrictions on what kind of plugins you can have or what attributes they can take as input.) - r3991 adds to the already-long list of legacy, non-conforming attributes that user agents may encounter in existing web content.
- r3871 and r3982 tweak the handling of Unicode surrogates. [Background: [whatwg] Surrogate pairs and character references]
Accessibility
As with so many things in the accessibility world, all of this week's changes revolve around the thorny problem of focus. I previously explained why focus is so important in episode 24.
- r3887 specifies that each
<area>
in a client-side image map should be focusable. - r3919 encourages browser vendors to expose tooltips to keyboard-only users. For example, in Firefox 3.5, if you hover your cursor over a hyperlink that defines a
title
attribute, you will see thetitle
attribute as a tooltip. But if you tab to the same link with the keyboard, no tooltip appears. Now imagine that you're physically unable to use a mouse, and you begin to see the problem. [Background: Bug 7362 and Issue 80] - r3928 defines an intriguing proposal about canvas accessibility, which probably deserves its own article. Here's the short version: you can already define "fallback content" within a
<canvas>
element that is shown to browsers that don't support the canvas API. This change dictates that the "fallback content" should remain keyboard-focusable even in browsers that do support the canvas API. To quote the spec: "This allows authors to make an interactive canvas keyboard-focusable: authors should have a one-to-one mapping of interactive regions to focusable elements in the fallback content." This is a draft proposal; as far as I know, no browser actually supports it yet, and it may get reverted in the future. [Background: Bug 7404] - r3969 clarifies that browsers must do nothing when the user activates a label whose corresponding input control is hidden (in any manner, including a
display: none
CSS rule). [Background: Bug 7583]
Security
All of this week's security-related changes revolve around document.domain
. As you might expect from its name, this property returns the domain name of the current document. Unfortunately (for security), the property is not read-only; you can also set document.domain
to pretty much anything. This can cause all sorts of horrible side effects, since so many things (cookies, local storage, same-origin restrictions on XMLHttpRequest
) rely on the domain of the document. This set of changes attempts to reduce the nasty side effects (and the possible attack surface) in case you absolutely must set document.domain
to something other than its default calcuated value.
- r3875 states that setting
document.domain
should release the storage mutex. (The storage mutex is a global lock that is acquired when setting cookies and released immediately afterwards. Since cookies are domain-specific, changing the domain dynamically like this needs to release the lock in case the page wants to update the cookies on the new domain.) [Background: [whatwg] Storage mutex and cookies can lead to browser deadlock, [whatwg] RFC: Alternatives to storage mutex for cookies and localStorage, [whatwg] Application defined "locks"] - r3878 states that setting
document.domain
makes Web Storage unusable, to avoid deadlocks with Web Storage's own locking mechanism. [Background: [whatwg] localStorage, the storage mutex, document.domain, and workers] - r3879 warns against setting
document.domain
on web applications that are hosted on shared servers. The spec explains the problem: "If an untrusted third party is able to host an HTTP server at the same IP address but on a different port, then the same-origin protection that normally protects two different sites on the same host will fail, as the ports are ignored when comparing origins after thedocument.domain
attribute has been used."
Semantics
- r3905, r3948, and r3966 clarify that the
profile
attribute (used by various microformats) takes a space-separated list of addresses, not just a single address. This has been the subject of heated debate for over 12 years, because HTML 4 claims that "the value of the profile attribute is a URI; user agents may use this URI in two ways..." while simultaneously claiming that "this attribute specifies the location of one or more meta data profiles, separated by white space." [Background: let's keep metadata profiles (head/@profile) in HTML for use in GRDDL etc., [whatwg] HTML4's profile="" attribute's absence in HTML5, Bug 7413, Bug 7484, Bug 7512, and Issue 55.] - r3869 tweaks the definitions of
<section>
,<article>
, and<details>
based on an informal study by Jeremy Keith. r3979 further tweaks the definition of<article>
, and r3978 mentions that the<article>
element is semantically similar to the<entry>
element in RFC 4287 (Atom Syndication Format). [Background: [whatwg] article/section/details naming/definition problems. Related: Bug 7551] - r3954 further clarifies the definition of
<footer>
. [Background: Bug 7502] - r3907 clarifies the workings of the registries for the enumerated values of
<link rel>
,<meta name>
, and<meta http-equiv>
attributes. - r3904 tweaks the semantics of
<link rel="up">
. - r3962 modifies the outline algorithm (used to generate a kind of "table of contents" of an HTML document based on sections and headers) to handle an obscure edge case. [Background: IRC discussion of edge case, Bug 7527, and in particular this comment on Bug 7527]
- r3987 gives an example to clarify that the
<nav>
element does not always need to be a child of a<header>
element.
Video
As regular readers of this column are aware, one of the big new user-visible features of HTML5 is native video support without plugins. As video is incredibly complicated, so to is the video support in HTML5. (Although not related to this week's changes, you may be interested to read my series, A gentle introduction to video encoding.)
- r3867 modifies the algorithm for sizing anamorphic video within a
<video>
element, and r3913 defines how to display a frame of anamorphic video in a canvas pattern. [Background: Re: video size when aspect ratio is not 1, What The Heck Is Anamorphic?] - r3924 defines what happens when you dynamically insert a
<source>
element as a child of a<video>
element that also has asrc
attribute, and r3925 defines what happens when you dynamically remove a<video src>
attribute. [Background: Bug 7631, Bug 7632] - r3927 gives advice on how browsers could render an
<audio>
element with acontrols
attribute. - r3992 makes further refinements to the
play()
andpause()
algorithms.
Web Forms
Forms continue to be difficult.
- r3874 allows browsers to reset the list of selected files of an
<input type="file">
element by setting itsvalue
attribute to the empty string. [Background: [whatwg] Setting .value on <input type=file>] - r3922 clarifies that setting the
disabled
attribute of a<fieldset>
element should not disable the children of the fieldset's<legend>
element. [Background: Bug 7591] - r3934 defines that the
maxLength
property should return -1 on a<textarea>
or<input>
element that does not include amaxlength
attribute. [Background: Bug 7427] - r3957 clarifies that implicit form submission should validate the form first. [Background: Bug 7511]
Interesting Discussion Threads This Week
- I like this proposal for adding a
document.head
property. It would presumably be faster thandocument.getElementsByTagName('head')[0]
, and more reliable thandocument.documentElement.firstChild
. - Character encoding on the web is even worse than you think.
- Re: On testing HTML
Around the Web
- Brad Neuberg: A video introduction to HTML5
- Google (my employer) released an intriguing project called Google Chrome Frame. It's a plugin for Internet Explorer that enables a number of new HTML5 capabilities on an opt-in basis. Here's a few technical details. Reaction has ranged from impressed to unimpressed to positively ironic. Google Wave is one of the first web applications to opt-in and suggest that Internet Explorer users download the plugin.
- Steve Faulkner: HTML5 & WAI-ARIA: Happy Families, a slide deck about current HTML5 accessibility features, misfeatures, and support in browsers and assistive technologies.
- Burst Engine is "an OpenSource vector animation engine for the HTML5 Canvas Element."
- Peter-Paul Koch: The HTML5 drag and drop disaster
Tune in next week for another exciting edition of "This Week in HTML5."