- From: Jukka K. Korpela <jukka.k.korpela@kolumbus.fi>
- Date: Thu, 09 Jan 2014 17:04:29 +0200
- To: public-html@w3.org
2014-01-05 19:31, Steve Faulkner wrote: > Currently the spec says its OK to use all h1's in a document or all > (h6's) for that matter as the heading rank is derived from the nesting > level of a heading within sections, not from the numerical value in > the elements name. Not quite. It associates (in 4.3.6) rank with the digit in the tag name: "These elements have a rank given by the number in their name. The |h1 <http://www.w3.org/html/wg/drafts/html/master/single-page.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>| element is said to have the highest rank, the |h6 <http://www.w3.org/html/wg/drafts/html/master/single-page.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>| element has the lowest rank, and two elements with the same name have equal rank." But it says (in 4.3.10): "The first element of heading content <http://www.w3.org/html/wg/drafts/html/master/single-page.html#heading-content-0> in an element of sectioning content <http://www.w3.org/html/wg/drafts/html/master/single-page.html#sectioning-content-0> represents <http://www.w3.org/html/wg/drafts/html/master/single-page.html#represent> the heading for that section. Subsequent headings of equal or higher rank <http://www.w3.org/html/wg/drafts/html/master/single-page.html#rank> start new (implied) sections, headings of lower rank <http://www.w3.org/html/wg/drafts/html/master/single-page.html#rank> start implied subsections that are part of the previous one. In both cases, the element represents <http://www.w3.org/html/wg/drafts/html/master/single-page.html#represent> the heading of the implied section." So indeed you could use h1 (rank 1) headings throughout (the first one would be the main heading, the others would each start a section), or h6 (rank 6) headings. I don't see what is gained by this freedom, especially since it old user agents (and possibly search engines) still only look at the rank. Moreover, the default (or "recommended" default) rendering rules (in 10.3.7) deal with one simple part of the consequences only: they specify rules reflecting the idea that "the |article <http://www.w3.org/html/wg/drafts/html/master/sections.html#the-article-element>|, |aside <http://www.w3.org/html/wg/drafts/html/master/sections.html#the-aside-element>|, |nav <http://www.w3.org/html/wg/drafts/html/master/sections.html#the-nav-element>|, and |section <http://www.w3.org/html/wg/drafts/html/master/sections.html#the-section-element>| elements are expected to affect the margins and font size of |h1 <http://www.w3.org/html/wg/drafts/html/master/sections.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>| elements". So if you have a <section> element with <h1> and <h2> inside it, then - on browsers that support this idea - the <h1> element is rendered as a level 2 element, but so is the <h2> element; it is not demoted to level 3, where it is logically supposed to be. The explanation is obvious: Writing all the rendering rules needed to reflect the logic of heading level demotion would be boring and would produce something rather bulky and messy-looking. > > Unfortunately while the above may be true in theory its not true in > practice. Quite right. Even if we optimistically expected browser vendors to eagerly implement the rules, it would take many years before authors could rely on them. Contrasting this with gain of the freedom, which is close to none, I think the logical conclusion should be that the classic HTML principles be restored in this respect: the rank of a heading dictates its level. It is a rather simplistic principle, but it has worked for a long time and has no real problem. Well, beyond the insertion issue: if you insert the content of a page, or a fragment of a page, into another page, e.g. as a <section> element, then the current HTML5 rules would demote any headings to reflect the new context. That would be fine, but the cost is too high, as added complexity of language (and its description, tutorials etc.), extra burden on implementations, and potential confusion (when authors misunderstand the complex concepts and definitions). Besides, the insertion issue has many other aspects as well, and the heading level demotion as among the more trivial problems. > > The current text in the spec can lead to authors creating flat > document outlines: > > "Sections may contain headings of any rank, and authors are strongly > encouraged to use headings of the appropriate rank for the section's > nesting level." > http://www.w3.org/html/wg/drafts/html/master/sections.html#headings-and-sections > > I am thinking that it may be better to have a normative requirement on > authors: > > "Authors SHOULD use headings of the appropriate rank for the section's > nesting level." I don't see a big difference between "strongly encouraged" and "SHOULD" (or, rather, "should", as per the convention mentioned in 2.2), though I know that in principle there is. For a "should" requirement, an author needs to have "valid reasons in particular circumstances to ignore a particular item" and needs to understand the full implications and carefully weigh them. But since "valid reasons" have not been defined objectively, anyone can say he has valid reasons, etc., so an author can claim conformance and you cannot refute that on objective grounds. Of course, the change would be an improvement, but very small. Note that you should then rewrite the following in 4.3.6, after an example that shows "classic" markup (heading rank equals level) and HTML5-style markup that uses <h1> inside <section> (for a heading that is at level 2 or level 3 in the document): "Authors might prefer the former style for its terseness, or the latter style for its convenience in the face of heavy editing; which is best is purely an issue of preferred authoring style." -- Yucca, http://www.cs.tut.fi/~jkorpela/
Received on Thursday, 9 January 2014 15:04:57 UTC