Markdown Heading Levels: Set and Adjust H1–H6
How Markdown sets H1–H6 headings, what changing heading levels actually alters, and when shifting levels helps or hurts structure, accessibility and copying.
Markdown gives you six heading levels, from H1 down to H6, and a simple way to mark them. Adjusting those levels, whether by hand or with a tool that promotes or demotes every heading at once, is a common step when merging documents, moving content between platforms or fixing an outline. This review explains what a heading-level change actually does to your text, where it reliably helps, and where it can quietly break structure or readability.
Short verdict: is adjusting heading levels right for your use?
Changing heading levels is a good fit when your Markdown will be rendered, such as in documentation sites, README files, static site generators or note apps, and you need the outline to nest correctly. The main benefit is structural: a renderer turns each level into a real heading element, which readers, assistive technology and many search systems use to understand the page. The decisive tradeoff is that heading levels only mean something where Markdown is rendered. A careless bulk shift can also damage content, for example by editing comment lines inside code blocks or pushing an H6 past the last available level.
Plain text without heading markup is preferable when the destination does not render Markdown, such as plain-text email, SMS, many chat inputs or form fields. There, the hash marks show up as literal characters and add clutter rather than structure. In those cases, a clear line of text, perhaps followed by a blank line, communicates a section break better than a heading marker.
How Markdown defines H1–H6
The most widely used form is the ATX heading: one to six hash characters at the start of a line, followed by a space and the heading text. The number of hashes sets the level. Under the CommonMark specification, the space after the hashes is required, up to three spaces of indentation are allowed before them, and a line with seven or more hashes is not a heading at all. Optional closing hashes at the end of the line are permitted and ignored.
# Heading level 1
## Heading level 2
### Heading level 3
#### Heading level 4
##### Heading level 5
###### Heading level 6
####### Not a heading in CommonMark
Markdown also supports Setext headings, which underline a line of text. A row of equals signs creates an H1 and a row of hyphens creates an H2. This style has no form for levels three through six, so content that needs deeper levels or level shifting is easier to manage in ATX style.
Page Title
==========
Section Title
-------------
Some older or non-CommonMark parsers accept a heading without the space after the hashes. Because behavior differs, writing the space every time is the safer habit.
What a heading-level change actually alters
Adjusting a heading level is a formatting change to the stored text. The characters in your file really do change: a line that began with two hashes now begins with three, or a Setext underline becomes an ATX prefix. Nothing about the heading words themselves changes. When the file is rendered, the new marker becomes a different HTML element, such as h3 instead of h2.
This is different from visual presentation. The size, weight and spacing of a rendered heading come from the destination's stylesheet, not from Markdown. Two sites can display the same H2 very differently, and a site's CSS can make an H4 look larger than an H3. If your goal is only a different look, a level change is the wrong tool; it changes the document's outline, which affects navigation and meaning.
It is also worth separating this from the other things people sometimes call a heading 'font'. Markdown headings do not substitute Unicode characters, reverse text or mirror glyphs. Text that has been converted into stylized Unicode letters to look bold or large is not a heading: it carries no heading semantics, may be read poorly or letter by letter by screen readers, and is harder to search and edit. If you want a heading, use heading markup.
Promoting and demoting headings in bulk
The most common adjustment is shifting every heading by the same amount. You might demote a standalone document by one level so it fits under a section of a larger guide, or promote a sub-document so it can stand on its own. A correct bulk shift should preserve the relative structure: if one heading sat one level below another before the change, it should still sit one level below it afterward.
Here is a demotion by one level. Note that the comment line inside the fenced code block starts with a hash but is not a heading, so it must stay unchanged.
Input:
# Installation Guide
## Requirements
## Steps
### Linux
```bash
# run as an administrator
sudo apt install example-package
```
Output after demoting by one level:
## Installation Guide
### Requirements
### Steps
#### Linux
```bash
# run as an administrator
sudo apt install example-package
```
When judging a tool or script that performs this shift, check for these failure points:
- Code blocks: a simple find-and-replace on lines starting with a hash will also alter shell, Python or YAML comments inside fenced or indented code blocks.
- The H6 limit: demoting an H6 would produce seven hashes, which is not a heading in CommonMark. A tool should warn, stop or clamp at H6 rather than silently turn the line into a paragraph.
- The H1 limit: promoting an H1 has nowhere to go, so the tool needs a defined behavior for that case too.
- Setext headings: pattern-based tools that only look for leading hashes may miss underlined headings entirely, leaving the outline inconsistent.
- Non-heading lines with hashes: hashtags or numbered references at the start of a line, such as a tag written without a following space, should not be counted as headings.
- Front matter: metadata blocks at the top of a file may contain a title field that the publishing system treats as the page's H1, which affects whether the body should start at H1 or H2.
Choosing levels that keep the outline readable
A practical pattern is to use a single H1 for the page or document title, H2 for main sections, and deeper levels only for genuine subsections. Avoid skipping levels, such as jumping from H2 straight to H4, because the outline then implies a missing section. Accessibility guidance, including the W3C's material on page structure, recommends that heading levels reflect the real hierarchy of the content rather than the visual size you want.
Whether the body should contain an H1 depends on the destination. Some publishing systems and documentation generators render the page title as an H1 on their own, in which case starting your Markdown body at H2 avoids two competing top-level headings. Check the destination's documentation rather than assuming; this review did not test specific platforms, so it cannot say which ones behave this way.
| Situation | Suggested approach |
| Standalone file rendered as its own page, with no separate title field | Start with one H1, then H2 for sections |
| Platform that renders the page title from metadata | Start the body at H2 |
| Embedding one document inside a section of another | Demote all headings so the top level sits below the parent section |
| Splitting a long document into separate pages | Promote each part so it begins with its own top level |
| Destination that does not render Markdown | Use plain text lines instead of heading markup |
Copying, sharing and accessibility
What survives copying depends on what you copy. Copying the raw Markdown keeps the hash markers, and a Markdown-aware destination will render them as headings again. Copying from a rendered page into a rich-text editor may carry heading formatting across, but that depends on the source and destination, and it was not tested here. Pasting into a plain-text field drops heading semantics completely; raw Markdown will show visible hashes, while rendered text will lose its structure and look like ordinary lines.
For accessibility, real headings are an advantage. Screen readers commonly provide a way to list or jump between headings, and they announce the heading level, so a logical H1–H6 outline helps people navigate long content. That benefit disappears if headings are faked with bold text, larger CSS or stylized Unicode characters. Whether a particular screen reader handles a given page well is something to confirm with that tool's documentation or a direct test, not to assume.
Editing and search behave the same way. Because the heading text itself is unchanged, it stays fully searchable and easy to edit after a level change. Search engines and site search can use rendered heading elements as signals of page structure, but a level change does not alter the words being indexed, and no claim is made here about ranking effects.
Provide a plain-text equivalent when the content is headed somewhere that ignores Markdown, when recipients will read it in plain-text email or messaging, or when you cannot confirm the destination renders headings. In practice that usually means removing the hash markers and keeping each heading as its own line, separated from the following text by a blank line.
What this review could not confirm
No specific editors, converters or heading-shift tools were tested for this review, so it does not rate individual products or report measured results. The behavior described above follows the CommonMark specification and general HTML and accessibility principles. Platform-specific details, such as which services render metadata titles as H1, how a given rich-text editor handles pasted headings, or how a particular assistive technology announces them, should be checked against each product's own documentation or a small test document before you rely on them.