Skip to content

MD020 - No missing space in closed heading

Aliases: no-missing-space-closed-atx

What this rule does

Ensures there's a space after the opening # and before the closing # in headings that use # symbols at both ends.

Why this matters

  • Readability: Spaces make the heading text easier to read
  • Compatibility: Some Markdown processors require spaces for proper rendering
  • Consistency: Maintains uniform heading formatting

Examples

✅ Correct

# Heading 1 #
## Heading 2 ##
### Heading 3 ###
#### Heading 4 ####
##### Heading 5 #####
###### Heading 6 ######

❌ Incorrect

#Heading 1#
##Heading 2##
###Heading 3###
#Heading 4 ####    (missing space at start)
##### Heading 5#####  (missing space at end)

🔧 Fixed

# Heading 1 #
## Heading 2 ##
### Heading 3 ###
#### Heading 4 ####
##### Heading 5 #####

Configuration

This rule has no configuration options.

Automatic fixes

This rule automatically adds spaces where they're missing:

  • After the opening # symbols
  • Before the closing # symbols

Learn more

  • MD018 - No missing space after hash in heading
  • MD019 - No multiple spaces after hash in heading
  • MD021 - No multiple spaces in closed heading
  • MD003 - Heading style should be consistent