Headings in Markdown
Start a line with # and a space to make a heading: one # for the main title, ## for sections, up to six levels. This guide covers the levels, the underlined style, ids and common mistakes.
Quick answer
How do you make a heading in Markdown?
Start the line with one to six # signs and a space: # Title is the largest heading and ###### Note the smallest. They become the HTML elements <h1> to <h6>. Use one # heading for the document title and ## for its sections.
# Document title
## Section
### SubsectionResult
Heading syntax and examples
The number of # signs sets the level. A few details decide whether a line becomes a heading at all.
The six levels
Each extra # goes one level down. Most documents need only the first three.
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6Result
A space after the hashes
Without the space, the line stays an ordinary paragraph.
#No space, no heading
# With a spaceResult
#No space, no heading
Underlined headings
A line of = or - under the text makes a level 1 or level 2 heading. This style has only these two levels.
Main title
==========
Section title
-------------Result
Closing hashes
Hashes after the text are optional and are left out of the heading.
## Installation ##Result
Formatting in headings
Headings can hold bold text, inline code and links.
### The `--force` option
### **Breaking** changes in [version 2](https://example.com/v2)Result
--force optionCustom heading ids
Pandoc, Hugo and kramdown accept an id in braces after the heading text, which # links can point to.
## Installation {#install}
[Jump to Installation](#install)Pandoc, Hugo and kramdown only. Other Markdown apps display this differently, so there is no preview.
Headings in popular apps
# headings work almost everywhere. Chat apps support fewer levels or none.
| App | Support | Notes |
|---|---|---|
| GitHub / GitLab | Supported | All six levels; every heading gets an id for # links. |
| Discord | Differs | #, ## and ### work in messages; -# makes small gray text. |
| Slack | Not supported | Messages have no headings; use bold text. |
| Obsidian | Supported | All six levels; headings fold, and [[Note#Heading]] links to them. |
| Notion | Differs | Typing #, ## or ### and a space makes a heading block. |
| Supported | All six levels work in posts and comments. |
Questions and answers
How many heading levels does Markdown have?
# for level 1 through ###### for level 6. They become <h1> to <h6> in HTML.Why is my heading not working?
# Title, not #Title) and start the line with them. Four or more spaces before the hashes turn the line into code.How do I link to a heading?
# and the heading's id: [Install](#installation). GitHub builds the id from the heading text in lowercase, with spaces turned into hyphens.How do I make a table of contents?
Should a document have only one # heading?
# heading?## for sections. Many websites print the page title as a heading already, so documents written for them start at ##.Can I give a heading my own id?
## Title {#my-id}.What is the difference between # headings and underlined headings?
# headings and underlined headings?# headings are more common and easier to spot in the source.How do I write headings in Discord?
#, ## or ### and a space. -# and a space makes small gray text.