22

HTML has a six level header system for document organization. The idea being that the <h1> level should have the page name, with <h2> subsections underneath. If further subsections are needed there are <h3>, <h4>, <h5>, and <h6>. So you could have some thing like

<h1>Page Name</h1>
  <h2>Sub-section</h2>
    <h3>Sub-sub-section</h3>
      <h4>Sub-sub-sub-section</h4>
        <h5>Sub-sub-sub-sub-section</h5>
          <h6>Sub-sub-sub-sub-sub-section</h6>
    <h3>Sub-sub-section 2</h3>

This provides a nice hierarchical organization. Stack Exchange sort of supports headers, but it’s entirely manual. And for some reason, two of the Markdown constructs create <h1> and <h2> headers, even in answers. So if people use the Markdown content as follows

Section 1
=========
Sub-section 1
-------------
Sub-section 2
-------------

If in the question body, we'd get

<h1>Question?</h1>
   <h1>Section 1</h1>
     <h2>Sub-section 1</h2>
     <h2>Sub-section 2</h2>
   <h2>COUNT Answers</h2>

and if in an answer, we'd see

<h1>Question?</h1>
  <h2>COUNT Answers</h2>
    <h1>Section 1</h1>
      <h2>Sub-section 1</h2>
      <h2>Sub-section 2</h2>

Eek! Either of those is wrong.

Note: I'm skipping a lot of content for brevity's sake. Presumably most people aren't composing their questions or answers entirely of headers. I'm leaving out the paragraphs, divs, etc.

So rather than have === and --- make h1 and h2 headers, could they instead be h2 and h3 in question bodies and h3 and h4 in answers?

Similarly, can you do one of the following?

  • Demote #, ##, ###, and #### to <h3>, <h4>, <h5>, and <h6> in answers?
  • Or demote # and ## to <h3> in answers and leave the others as is?

Either should change questions as well, but # would become <h2> instead of <h3> in questions.

The first better preserves the existing hierarchy while the second better preserves the intentions of people who currently use <h3> headers to denote top level sections of answers. Either would tend to lead to a lot of Markdown content being slightly wrong, as one preserves semantics while the other preserves display.

Note: a side issue is that search engine optimization works best if there is only one h1 per page and it has the same content as the page <title>.

Examples of problems that arise in the current system:

Note that both those problems would be fixed by this proposal. No one would use an <h1> or <h2> tag via Markdown in an answer anymore.

9
  • 1
    search engine optimization works best as if there is an issue with Stack Overflow content being indexed by Google now.
    – rene
    Dec 27, 2015 at 9:42
  • 1
    @rene Perhaps there is -- on pages where h1 headers are used for something other than the question. That many pages are well optimized doesn't mean that all of them are.
    – Brythan
    Dec 27, 2015 at 14:01
  • Your proposal would require that h1 and h2 are expelled from being used in the markdown editor or that their current meaning is changed, something the upcoming spec for commanmark was going to fix.
    – rene
    Dec 27, 2015 at 14:10
  • I agree that it requires either expelling them or changing their meaning. I don't agree that the linked spec for CommonMark fixes the problems noted here. Nor would I say that StackExchange should support the standard even when it conflicts with StackExchange's design. That would seem more a reason to pick one fix over another.
    – Brythan
    Dec 27, 2015 at 22:57
  • Well, Balpha is one of the co-authors of the commonmark spec and I believe feature owner on SE for PageDown and Markdownsharp. I expect them to implement and adhere that spec for their posts. I still see no major benefit in fixing or implementing your proposal.
    – rene
    Dec 27, 2015 at 23:07
  • Only the first three levels are supported (<h1>, <h2>, and <h3>). May 31 at 11:29
  • 2
    @This_is_NOT_a_forum: That comment is outdated. See this post for an example of all 6 levels of headings supported on Stack Exchange, plus bolded text and regular text for comparison. (I'm just using it as an example of how the header formatting is rendered; the text of the linked post itself is no longer accurate, as it was written years ago.)
    – V2Blast StaffMod
    May 31 at 17:13
  • That said, that MSO post is very related: Accessibility concerns about Stack Overflow
    – V2Blast StaffMod
    May 31 at 17:14
  • 4
    I agree more with the answer below that the styling of our headings is very off-putting. I never use H1s (and rarely H2s) here merely because they are ridiculously huge. But as an aside: your direct request of changing how these syntaxes work will never happen. We explicitly follow the CommonMark standard and will not deviate from it.
    – animuson StaffMod
    May 31 at 17:28

1 Answer 1

1

This is a question about mechanics, from a mechanic to non-mechanics. Normal people will see it as splitting hairs.

This should be about changing the style, so even this header 1 is not so enormous.

That looks hideous. So, why did the OP ask in the first place? Why not put more focus on the font style? Right or wrong, there is an explanation for why this even came up...

In the HTML coding world where Markdown came from, we get constantly lectured about how we're "supposed" to honor the DOM (Document Object Model) and use it properly for accessibility.

Understand DOM’s power in the browser object hierarchy:

Once you have a handle on the DOM hierarchy, its relationships to scripting and browsers, and its OOP features, you can go beyond simply writing more efficient scripts: You can use the objects of the DOM hierarchy as building blocks for far more sophisticated Web apps than you’ve ever imagined writing. You can create complex structured documents and employ sophisticated navigation techniques that can empower a Web app to the level of the most intricate in-house real-time database apps. You can even assemble virtual documents for your client’s Web users’ convenience from multiple sources and keep everything straight via DOM.

See the kind of pressure we software folk deal with?

It admittedly does make a difference to other application developers, browsers, and search engines. For instance, if you have a # header 1 in your question, Google might take more note of it than if you simply use **bold**.

There's a bigger issue

See how huge that # header 1 text is? We're "supposed" to use that in our posts. But no one does because it's so ridiculously huge. It's bigger than the title for the question itself!

More than whether the HTML DOM honors the hierarchies "properly", we need to get rid of that enormously atrocious front page headline font typeface and get fonts and sizes that make the Markdown hierarchies more attractive to use.

3
  • 1
    "See how huge that # header 1 text is? We're "supposed" to use that in our posts": No, not from an accessibility standpoint. May 31 at 11:33
  • @This_is_NOT_a_forum with all respect, that's not what it explains. The key is skip levels or unnecessarily reset the levels. My # header 1 does not skip or unnecessarily reset, according to HTML DOM models. If it were ## header 2 without a # header 1 above it, then that would be a problem for accessibility. But, thanks for that article. It really helps. May 31 at 13:25
  • @This_is_NOT_a_forum and, I'd like to say that there's another issue here, that many users don't even know how to use Markdown or "hierarchy" for accessibility/DOM purposes. Maybe that should go in the tours or something. May 31 at 13:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .