How to add a horizontal line in Markdown
Try it — edit the markdown and watch the preview
Result
Runs entirely in this tab. Open the full editor to work on a real document.
Three dashes on their own line make a horizontal rule — a <hr> in the output,
a full-width dividing line on the page.
---
Asterisks (***) and underscores (___) do exactly the same thing. Any of the
three works, and three characters is the minimum.
The one thing that catches people out
Put dashes directly under a line of text and you do not get a rule:
My heading
---
That is Setext heading syntax, and it renders “My heading” as an H2. It is the single most common surprise with horizontal rules. The fix is a blank line:
My heading
---
Now the text is its own paragraph and the dashes are a rule.
Front matter uses the same characters
A block fenced by --- at the very top of a file is YAML front matter — a
metadata block, not a divider. All Markdown hides it from the preview and shows
a small note instead, so you can see at a glance that it was recognised as
metadata rather than silently dropped.
Common questions
- What is the standard way to write a horizontal line?
- Three or more dashes on their own line, surrounded by blank lines. Asterisks and underscores work identically, but dashes are by far the most common and the easiest to read in raw source.
- Why did my dashes turn the line above into a heading?
- Dashes directly underneath a line of text are Setext heading syntax — that combination makes an H2, not a rule. Leave a blank line between the text and the dashes and you get the horizontal line you wanted.
- Does the number of dashes matter?
- No. Three is the minimum and any number above that renders the same. Some teams write a full row of dashes so the separator is visible while scanning the raw file.
- Can I put spaces between the characters?
- Yes. "- - -" is valid and renders the same as "---". The characters must all be the same, though; mixing dashes and asterisks on one line produces a paragraph of punctuation instead.
- How is a horizontal rule different from front matter?
- Front matter is a block fenced by three dashes at the very top of a file, holding metadata. A rule is a single line of dashes anywhere else. Position is what tells the two apart.