- From: <whatwg@robertdot.org>
- Date: Mon, 12 Mar 2007 14:53:45 -0600 (CST)
> XHTML2 moves a lot of semantics and behavior from elements to global > attributes. For example, href can turn any element into a hyperlink, > and src can turn any element into an image. I liked the href adding a link to any object, but the src, I don't care for. I can already set a background image on an element to "turn it into an image." As I followed the thread you mentioned, I could see cases where code would be cleaner to, for example, have an href in a heading element. That would solve some issues with inline elements holding block elements (e.g. improperly adding an anchor to an entire h1 tag). > - It's easier (and, in many implementations, more efficient) to style > by tag name rather than by presence or absence of an attribute. As I followed the thread, thinking about styling the element was the clincher for me. IE 6 doesn't support attribute based selectors. So, I, for one, couldn't use it until IE 6 (haven't tested attribute selectors in IE 7, since I stopped using them in light of IE 6) lost most of it's popularity. After that, having the href in, say, an ordered list used for navigation would save a few keystrokes. > - Typically, browser implementations have an implementation class per > element, but not a class per attribute, so putting primary semantics > and behavior on an element instead of an attribute promotes clean > implementation. Otherwise, all behavior ends up in the HTMLElement > base class. I can certainly see how this would trouble an implementor. If it made working with DOM objects (e.g. looping through an object's properties) more tedious, developers would certainly care. > Finally, I'd like to conclude with this reductio ad absurdum of the > XHTML2 approach. If assigning behavior and semantics to attributes is > so much better, why not just have a single <elt> element: While the href attribute is pretty common (lots of things need to be links that are already wrapped in some kind of tag) and could simplify code, the src element definitely seems to follow this reduction. Having a few select attributes (specifically the href) applicable to all tags could be useful. But, I agree with you in the end. The potential problems and compromise of semantics is important enough either not to have it, or not to use it if it is available if you desire a semantic document (ignoring things like the title, lang, etc that really do need to be available). -- Robert Brodrecht <http://robertdot.org>
Received on Monday, 12 March 2007 13:53:45 UTC