49

Any inline code block inside a header gets rendered with the same font-size as normal paragraphs, and this makes code look very inappropriate inside headers.

For example, the following Markdown:

Just a regular header, with some `code` in it
====

Just a regular paragraph.

Produces this output:

output
NOTE: same goes for smaller headers

I mean, what's this? Ewww. Please take a look at it and update the CSSs!

14
  • 13
    Ehm, why would you ever put code in a header?
    – Robert Harvey Mod
    Commented Jan 19, 2015 at 0:28
  • 33
    @RobertHarvey Perhaps if you wanted a header that said "How to use XDocument", for instance? Doesn't seem that outlandish to me.
    – JLRishe
    Commented Jan 19, 2015 at 0:31
  • 5
    @RobertHarvey look at this answer, for example. I've seen tons of answers containing code in headers, for example most of the reference answers do have headers containing code blocks. Commented Jan 19, 2015 at 0:35
  • 6
    @JLRishe: Except that doesn't really benefit from the use of the code block.
    – Ben Voigt
    Commented Jan 19, 2015 at 3:43
  • 3
    @BenVoigt I guess all I can say is that I disagree. I think it makes perfect sense stylistically to demarcate code even when it's in a title. I think a lot of tech authors would agree with me. It looks like the authors of You Don't Know JS do: Example 1 Example 2 Example 3
    – JLRishe
    Commented Jan 19, 2015 at 5:47
  • @JLRishe I agree. Plus: any text inside a header should be a bigger size, as per the definition of header itself. Something with mixed font sizes isn't a header. Commented Jan 19, 2015 at 7:24
  • 1
    @JLRishe: To go with your example, there's not a single code snippet in the Table of Contents Apparently all your examples are not titles, but subsubheadings. Anyway, all those titles could have been expressed without special formatting, and would then have been more meaningful wherever they were repeated as plain text only (e.g. a Table of Contents, or a PDF bookmark list). If your title text depends on font changes to make its meaning clear, it is not a good title.
    – Ben Voigt
    Commented Jan 19, 2015 at 7:43
  • Looks like this question is going to be closed as opinion-based. Ahah. Commented Jan 19, 2015 at 7:49
  • 6
    @BenVoigt The text that this question is referring to is also a sub(sub)heading. It's never going to be used in a table of contents. The use of code blocks allows it to be more expressive and makes just as much sense as using a code block in the middle of a paragraph of regular text. I don't see how it makes any sense to have a drastic font-size disparity just because part of the text is code.
    – JLRishe
    Commented Jan 19, 2015 at 7:54
  • 3
    @JLRishe: I agree (a lot) that code in headers might be useful. I disagree that your XDocument example is a good one. Commented Jan 19, 2015 at 17:48
  • 2
    This answer of mine uses code blocks in headings because the headings introduce different sections that can only be helpfully identified in code. Unlike the XDocument situation @LightnessRacesinOrbit disagrees with, here the code (1) meaningfully identifies different sections; and (2) must be code-formatted, otherwise it will be illegible; it's not just a single identifier. Commented Jan 19, 2015 at 20:10
  • 13
    zomg to the "I found a bug", "nah, it's not a bug, no one should ever use that" Commented Jan 19, 2015 at 21:14
  • 1
    @MichaelGazonda that's pretty accurate. Commented Jan 19, 2015 at 21:16
  • Could we place tags in header? Commented Apr 20, 2015 at 21:11

1 Answer 1

15

Even thought there haven't been answers, it looks like the issue has been solved. As of now, writing the following Markdown code:

Just a regular header, with some `code` in it
====

Just a regular paragraph.

will produce this output:

example

(same goes for smaller headers)

So yeah, looks like the developers solved it silently. And everyone lived happily ever after.

You must log in to answer this question.

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