Re:Do we need a new heading element in HTML?
by tyingq on Monday February 20, 2017 @08:46AM
(#13687124)
Surprised it wouldn't come with a new attribute, like level, in case you don't trust the browser to autocalc... <h level=1>
[ Parent
| on HN ]
Re:Do we need a new heading element in HTML?
by jaffathecake on Monday February 20, 2017 @08:51AM
(#13687156)
This kinda already exists https://www.w3.org/TR/wai-aria/states_and_properties#aria-le...
Re:Do we need a new heading element in HTML?
by tyingq on Monday February 20, 2017 @09:39AM
(#13687579)
That's mentioned in the github thread. Would it be, though, the first time changing an aria-whatever attribute would have a visual effect on the page (without specific css)?
Re:Do we need a new heading element in HTML?
by jaffathecake on Monday February 20, 2017 @09:52AM
(#13687690)
Huh, good point. I can't find any pseudo-class that's affected by aria.
Re:Do we need a new heading element in HTML?
by mamadrood on Monday February 20, 2017 @08:58AM
(#13687220)
Then what would be the difference between <h level=1> and <h1> ? Or is that sarcasm ?
Re:Do we need a new heading element in HTML?
by tyingq on Monday February 20, 2017 @09:04AM
(#13687274)
Because you can manipulate attributes without destroying and recreating elements. Changing <h level=1> to <h level=2> is a much simpler and different thing to changing <h1> to <h2>.
An alternative approach to 100% trusting the browser to calculate the level. You can calculate and adjust as needed.
Re:Do we need a new heading element in HTML?
by esrauch on Monday February 20, 2017 @09:18AM
(#13687379)
Can you explain in what ways it is simpler to change 1 to 2 in the first case? Is it that you are mutating them via script and it seems more "normal" to mutate a property of a tag instead of the tagname?
Or is it because it might have a named closing tag and you have to update both?
Re:Do we need a new heading element in HTML?
by tyingq on Monday February 20, 2017 @09:23AM
(#13687429)
You can't change a tag name with a script. You have to destroy it and create a new one, being sure to copy attributes and the inner html, then, inserting the new one in the right spot. That's not only more work at a script level, I assume it's much more disruptive at a browser internals perspective regarding reflow, etc.
Using an attribute would also allow you to programmatically get the nested level from the dom if the browser had "levelled" the <h> tags on it's own. Lacking that, I don't think you could tell what the browser ended up doing.
Edit: It basically comes down to whether you're okay with the browser auto calculating the level of <h>, and then not having any programmatic access to what it decided. If you don't care, then <h> without an attribute works fine.
Re:Do we need a new heading element in HTML?
by walterstucco on Monday February 20, 2017 @10:28AM
(#13688038)
then add data-level=N to H1…