Markdown Headings

Last updated: 2026-10-14

Headings CommonMark core

Start a line with # to create a heading; the number of # marks is the level (1-6) and a space must follow. Headings structure your document: usually one top-level heading per page, then level 2 and 3 below.

GroupBasic: Block
Spec levelCommonMark core
Spec versionCommonMark 0.31.2 + GFM

📝 Syntax

# Level 1
## Level 2
###### Level 6

▶ Live Example

Edit Markdown on the left, see the result on the right

💡 Key points

💡 Tip The space after # is required: #heading will not parse as a heading.
ℹ️ Note Use levels in order and avoid skipping (h2 to h4) — it helps SEO and accessibility.

❓ FAQ

Q Is there a level-7 heading?
A No. HTML only has h1-h6; 7 or more # renders as plain text.
Q Can a page have multiple top-level headings?
A Syntactically yes, but best practice is one h1 per page with h2 and below for the rest.
Q How to add an anchor to a heading?
A Use the extension ## Heading {#custom-id} — see the heading-ids entry.

📚 See also

ParagraphsCommonMark core Setext HeadingsCommonMark core Heading IDsCommon extension
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏