google / google/styleguide

Markdown: ATX-style headers should focus on consistency for justification

Open
#631 12 comments 0 reactions 0 assignees View on GitHub
lang:markdown
Dominant language
HTML
Stars
39.6k
Forks
12.9k
Avg merge
42m
Merged PRs (30d)
15

Description

> Headings with `=` or `-` underlines can be annoying to maintain and don’t fit with the rest of the heading syntax. The user has to ask: Does `---` mean H1 or H2?

— [Markdown style guide: ATX-style headings](https://google.github.io/styleguide/docguide/style.html#atx-style-headings)

The stated rationale for dismissing Setext headers due to confusion between `=` and `-` appears to be a pre-emptive use of the *tu quoque* fallacy, since there doesn’t seem to be any actual or likely confusion (`=====` is clearly a heavier/double underline vs `-----`), while `###### This is an H6` has much greater visual emphasis than `# This is an H1`, which isn’t much more visually distinct than a list item: `* This is a list item`. An atx H1 `# This in an H1` being greater than an atx H2 `## This is an H2` is also inconsistent with Markdown syntax defining `*emphasis*` as less than `**strong emphasis**`, in terms of increasing decoration. Confusion is a bigger problem for atx than Setext.

Visually, a single `#` character is easy to miss, though it is meant to indicate the header of greatest importance. The `#` character also denotes a comment in many languages, and if you include any of those in your document, e.g. distinguishing between a PowerShell comment and an H1 header becomes quite context-dependent. Headers like `# Products` can even read as “number of products” when scanning a text quickly, especially when missing the context of the Markdown syntax in unrendered/unhighlighted environments like database field values.

``````markdown
# PowerShell command line options

The PowerShell executable offers several command-line parameters than can be abbreviated to the minimum
# of characters that disambiguate them.

```powershell
# good options for Scheduled Tasks and simple one-liners
powershell.exe -NoLogo -NonInteractive -NoProfile -File C:\Scripts\Backup-Data.ps1

# shortened
powershell.exe -nol -noni -nop -f C:\Scripts\Backup-Data.ps1

# simple one-liner to list Windows file shares
powershell.exe -nol -noni -nop -Command "& {Get-WmiObject Win32_Share}"
```
``````

Underlining headers provides a strong, natural visual decoration.

Readability is the primary design goal of Markdown over other formats, and the ease of writing and parsing atx headers doesn’t contribute to that goal.

I've made an honest attempt at a fair and thorough comparison of the four possible Markdown headings at [Setext vs atx Header Styles in Markdown](http://webcoder.info/markdown-headers.html).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.