HTML5 and CSS3 in The Real World

de Alexis Goldstein
Copertă HTML5 and CSS3 in The Real World
HTML5 and CSS3 in The Real World
Anul Publicării:

Heard of Sjoerd Visscher? I’d venture to guess you haven’t, but what he considered a minor discovery is at the foundation of our ability to use HTML5 today. Back in 2002, in The Hague, Netherlands, Mr. Visscher was attempting to improve the performance of his XSL output. He switched from createElement calls to setting the innerHTML property, and then realized that all the unknown, non-HTML elements were no longer able to be styled by CSS. Fast forward to 2008, and HTML5 is gaining momentum. New elements have been specified, but in practice Internet Explorer versions 6-8 pose a problem, as they fail to recognize unknown elements; the new elements are unable to hold children and CSS has no effect on them. This depressing fact was posing quite a hindrance to HTML5 adoption.

Now, half a decade after his discovery, Sjoerd innocently mentions this trick in a comment on the blog of the W3C HTMLWorking Group co-chair, Sam Ruby: “BTW, if you want CSS rules to apply to unknown elements in IE, you just have to do document.createElement(elementName). This somehow lets the CSS engine know that elements with that name exist.” Ian Hickson, lead editor of the HTML5 spec, was as surprised as the rest of theWeb. Having never heard of this trick before, he was happy to report: “This piece of information makes building an HTML5 compatibility shim for IE7 far easier than had previously been assumed.”

HTML5 and CSS3 in The Real World