Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MD022 - Blanks Around Headings

Headings should be surrounded by blank lines.

Why This Rule Exists

Blank lines around headings improve readability and ensure consistent rendering across Markdown parsers. Some parsers require blank lines to properly recognize headings.

Examples

Incorrect

Some paragraph text.
## Heading
More text here.

Correct

Some paragraph text.

## Heading

More text here.

Configuration

[MD022]
lines_above = 1  # Blank lines before heading (default: 1)
lines_below = 1  # Blank lines after heading (default: 1)

When to Disable

  • Documents with compact formatting requirements
  • Content where headings immediately follow other headings

Rule Details

  • Rule ID: MD022
  • Aliases: blanks-around-headings
  • Category: Structure
  • Severity: Warning
  • Auto-fix: Yes
  • MD023 - Headings start at beginning of line
  • MD031 - Blanks around fenced code blocks
  • MD032 - Blanks around lists