[whatwg] New attributes would degrade better than new elements

On Wed, Oct 26, 2011 at 12:38 PM, Jukka K. Korpela <jkorpela at cs.tut.fi> wrote:
> New elements like <nav> and <footer> have the problem that some existing
> user agents don't recognize them, even for the purposes of styling. So if
> you want to use <nav>, then - unless you're using it for purely semantic
> reasons with no idea of styling - you need to use some special trick to make
> old browsers recognize it or assign your styles to some logically redundant
> <div> markup that you use in addition to <nav>.
>
> Therefore, it would be much simpler, for compatibility with existing user
> agents, to use just <div type=nav> and <div type=footer>. Such elements can
> be styled at will, and if any browsers or search engines wish to recognize
> semantic markup, type=nav should not be a bigger problem than <nav>, rather
> smaller.
>
> I understand that this should have been suggested years ago. But I didn't
> think of the issue, and it seems that neither did anyone else, aloud. And
> it's not too late, is it?
>
> Nobody needs new elements with no required functionality, really. The idea
> of more compact markup is pointless. People don't read or write markup that
> much, and if they do, <div type=nav> is no less semantic than <nav>. But the
> latter has the serious drawback of being ignored by many relevant user
> agents.
>
> It does not need to be the 'type' attribute of course. That attribute name
> is seriously overloaded, so 'kind' might be better. The important thing is
> to introduce an attribute different from 'class', which currently lets
> authors use a free naming space. We don't want to interfere with style
> sheets that might use this or that 'class' attribute value; instead, a new
> attribute name (defined as semantic, not presentational, but still useful
> for styling) is called for - rather than new element names, which are born
> homeless.

Believe me, these discussions were had in the past.

All major UAs except old IE handle unknown elements in a way that's
acceptable for <nav> and friends.  They have the absolute default
styling (such as display:inline), but that's fine, as you can still
target them and restyle them.

In old IE the new elements are instead parsed as two void elements
named "<nav>" and "</nav>", but the IE shiv has been around for years
now that fixes that with a one-liner in JS.  Once you run that, you're
in the same situation as other major browsers.

So, it's not a big deal.  (Plus, modern browsers *do* recognize the
new elements natively now.)

~TJ

Received on Wednesday, 26 October 2011 13:16:45 UTC