Home/Docs/Markdown Horizontal Rules

Markdown Horizontal Rules

Learn how to create horizontal rules in Markdown using hyphens, asterisks, and underscores.

This guide explains the correct syntax, practical examples, GitHub compatibility, best practices, common mistakes, and FAQs.

A Markdown horizontal rule is a visual divider that separates sections of content. It helps organize long documents by creating a clear break between topics and is widely supported across GitHub, VS Code, Obsidian, and other Markdown editors.

Practice as you read: Open the Markdown Editor to create horizontal rules with live preview, or keep the Markdown Cheat Sheet open for quick syntax lookup.

Open EditorDownload PDF

What Is a Markdown Horizontal Rule?

A Markdown horizontal rule is a visual divider that separates sections of content. It helps organize long documents by creating a clear break between topics.

Horizontal rules improve readability and make documentation easier to scan, especially in:

  • GitHub README files
  • Technical documentation
  • User guides
  • Tutorials
  • Blog articles
  • Knowledge bases
  • Project documentation

Instead of using blank lines or repeated characters, Markdown provides a dedicated syntax for creating section dividers.

Why Use Horizontal Rules?

As documentation grows, readers need visual cues to identify where one section ends and another begins.

Horizontal rules help you:

  • Separate major sections
  • Improve readability
  • Break up long articles
  • Organize documentation
  • Highlight transitions between topics
  • Make README files easier to scan

Well-placed horizontal rules create a cleaner reading experience without adding unnecessary complexity.

Markdown Horizontal Rule Syntax

Markdown supports three different ways to create a horizontal rule.

All of the following produce the same result.

Using Hyphens

---

Output

Rendered Output


Hyphens are the most commonly used option and are recommended for consistency.

Using Asterisks

***

Output

Rendered Output


Using Underscores

___

Output

Rendered Output


Although all three styles are valid, most documentation projects choose one style and use it consistently.

Minimum Characters Required

A horizontal rule requires at least three matching characters.

These are valid:

---

***

___

These are not valid:

--

**

__

Using fewer than three matching characters will not create a horizontal rule.

Horizontal Rule Examples

# Introduction

Content goes here.

---

# Installation

Installation instructions.

Output

Rendered Output

Introduction

Content goes here.


Installation

Installation instructions.

This is one of the most common layouts used in GitHub README files.

When Should You Use Horizontal Rules?

Horizontal rules work best when separating major sections such as:

  • Introduction
  • Installation
  • Features
  • Usage
  • Configuration
  • API Reference
  • Examples
  • FAQ
  • License

Avoid placing horizontal rules between every paragraph, as excessive use can make documents feel cluttered.

Horizontal Rules with Headings

One of the most common uses of horizontal rules is separating major headings.

# Introduction

Welcome to the guide.

---

# Installation

Follow these installation steps.

---

# Usage

Learn how to use the project.

Output

Rendered Output

Introduction

Welcome to the guide.


Installation

Follow these installation steps.


Usage

Learn how to use the project.

This layout is widely used in GitHub README files and technical documentation because it clearly separates major sections.

Horizontal Rules with Lists

Horizontal rules can separate different lists or groups of information.

## Frontend

- HTML
- CSS
- JavaScript

---

## Backend

- Node.js
- Express
- MongoDB

Output

Rendered Output

Frontend

  • HTML
  • CSS
  • JavaScript

Backend

  • Node.js
  • Express
  • MongoDB

This approach makes long documentation easier to scan.

Horizontal Rules with Code Blocks

Horizontal rules help distinguish different code blocks.

```bash
npm install
```

---

```bash
npm run dev
```

Output

Rendered Output

npm install

npm run dev

Separating examples improves readability, especially in tutorials and API documentation.

Horizontal Rules with Tables

| Name | Role |
|------|------|
| John | Admin |
| Sarah | Editor |

---

| Product | Price |
|---------|------:|
| Laptop | $999 |
| Mouse | $29 |

Horizontal rules make it easy to distinguish between multiple tables in the same document.

Horizontal Rules with Images

![Project Screenshot](image-1.png)

---

![Dashboard Preview](image-2.png)

Using dividers between screenshots creates a cleaner visual layout in documentation and tutorials. See Markdown Images for image syntax details.

Horizontal Rules with Blockquotes

> **Important**
>
> Always create a backup before updating.

---

> **Tip**
>
> Test your changes locally before deploying.

Output

Rendered Output

Important

Always create a backup before updating.


Tip

Test your changes locally before deploying.

Combining blockquotes with horizontal rules makes notes and tips stand out without cluttering the page.

Horizontal Rules in GitHub

GitHub fully supports all three Markdown horizontal rule syntaxes:

  • ---
  • ***
  • ___

Most GitHub repositories prefer using three hyphens (---) because they are easy to read and commonly used throughout documentation.

Horizontal rules work in:

  • README files
  • Wikis
  • Issues
  • Pull Requests
  • Discussions
  • GitHub Pages

For consistency, use the same style across your entire repository.

Platform Compatibility

Platform Horizontal Rules Supported
GitHub βœ…
GitLab βœ…
VS Code Preview βœ…
Obsidian βœ…
Notion βœ…
Stack Overflow βœ…
Docusaurus βœ…
MkDocs βœ…
Hugo βœ…
Astro Starlight βœ…

Horizontal rules are part of the CommonMark specification, making them one of the most widely supported Markdown features across editors and documentation platforms.

Best Practices

Using horizontal rules consistently makes Markdown documents easier to read and navigate. Follow these best practices when adding section dividers.

Use Horizontal Rules Only Between Major Sections

Horizontal rules are intended to separate large sections of content rather than individual paragraphs.

Good example:

# Installation

Installation instructions...

---

# Usage

Usage examples...

Avoid inserting a divider after every paragraph, as it can make the page feel cluttered.

Choose One Style

Markdown supports three valid syntaxes:

---

***

___

Although all three produce the same result, it's best to choose one style and use it consistently throughout your documentation.

For most projects, three hyphens (---) are the recommended choice.

Leave Blank Lines Around Horizontal Rules

For better compatibility, leave one blank line before and after each horizontal rule.

Good example:

First section.

---

Second section.

This improves readability and ensures consistent rendering across Markdown editors.

Don't Replace Headings with Horizontal Rules

Horizontal rules separate contentβ€”they do not replace headings.

Instead of writing:

Introduction

---

Installation

Use proper headings:

# Introduction

Content...

---

# Installation

Content...

This creates a better document structure and improves accessibility.

Preview Before Publishing

Always preview your Markdown document to verify that horizontal rules render correctly.

Most editors, including GitHub, VS Code, Obsidian, and Markdown preview tools, display horizontal rules consistently. Preview in the Markdown Editor before publishing.

Common Markdown Horizontal Rule Mistakes

Even though horizontal rules are simple, a few common mistakes can prevent them from rendering correctly.

Using Fewer Than Three Characters

Incorrect:

--

Correct:

---

A horizontal rule requires at least three matching characters.

Mixing Different Characters

Incorrect:

-*-

Correct:

---

or

***

or

___

Always use the same character throughout the entire rule.

Forgetting Blank Lines

Although some Markdown parsers accept it, placing blank lines around horizontal rules improves compatibility and readability.

Recommended:

Paragraph one.

---

Paragraph two.

Confusing Headings with Horizontal Rules

Remember that headings organize document structure, while horizontal rules simply divide sections.

Use both together for the best reading experience.

Real-World Examples

Horizontal rules are commonly used in documentation projects.

README Structure

# Project Name

Project description.

---

## Installation

Installation steps.

---

## Usage

Usage examples.

---

## License

MIT

Documentation Guide

# API Documentation

Authentication details.

---

# Endpoints

List of API endpoints.

---

# Error Codes

Common API responses.

Tutorial Article

# Step 1

Prepare your environment.

---

# Step 2

Install dependencies.

---

# Step 3

Run the application.

These layouts are widely used in GitHub repositories, documentation websites, and developer blogs because they create a clear visual separation between major sections.

Practice Markdown Horizontal Rules

The easiest way to understand horizontal rules is to experiment with them.

Open the Markdown Editor and try creating dividers using hyphens, asterisks, and underscores. Preview the rendered output instantly and compare how different Markdown elements work together.

You can also export your Markdown as HTML, PDF, or other supported formats using the Markdown to HTML and Markdown to PDF conversion tools.

Summary

Markdown horizontal rules are a simple but powerful way to organize documentation and improve readability.

In this guide, you learned:

  • What horizontal rules are
  • Three valid Markdown syntaxes
  • When to use section dividers
  • Real-world examples
  • GitHub compatibility
  • Common mistakes to avoid
  • Best practices for clean documentation
  • Frequently asked questions

Whether you're writing a GitHub README, technical documentation, tutorials, or knowledge base articles, horizontal rules help readers navigate long documents more easily and create a cleaner, more professional layout.

Continue Learning

Continue learning Markdown with these guides:

Available now

The best way to learn horizontal rules is by writing them yourself. Open the Markdown Editor to experiment with dividers, headings, lists, and blockquotes while previewing the rendered output in real time.

Frequently Asked Questions

  1. 1

    What is a horizontal rule in Markdown?

    A horizontal rule is a visual divider that separates sections of content in a Markdown document. It improves readability by creating a clear break between topics.

  2. 2

    How do I create a horizontal rule in Markdown?

    Use three or more matching characters on a separate line. Example: ---. You can also use *** or ___. All three produce the same horizontal line.

  3. 3

    Which horizontal rule syntax is recommended?

    Although Markdown supports hyphens (---), asterisks (***), and underscores (___), most developers and documentation projects use three hyphens (---) because they are easy to read and widely adopted.

  4. 4

    Does GitHub support Markdown horizontal rules?

    Yes. GitHub Flavored Markdown fully supports horizontal rules created with ---, ***, and ___. They work in README files, Wikis, Issues, Discussions, Pull Requests, and GitHub Pages.

  5. 5

    Can I use more than three hyphens?

    Yes. For example, ------ is also valid. However, using exactly three characters keeps your Markdown cleaner and more consistent.

  6. 6

    What's the difference between a horizontal rule and a line break?

    A line break moves text to the next line. A horizontal rule creates a visible divider between two sections of content. They serve completely different purposes.

  7. 7

    Why isn't my horizontal rule working?

    The most common causes are using fewer than three matching characters, mixing different characters (for example -*-), placing other text on the same line, or incorrect spacing. Always place the horizontal rule on its own line.

  8. 8

    Can I use horizontal rules inside lists or blockquotes?

    Yes. Most Markdown editors support horizontal rules inside lists and blockquotes, although indentation must be correct for consistent rendering.

  9. 9

    Do all Markdown editors support horizontal rules?

    Yes. Horizontal rules are part of the CommonMark specification and are supported by GitHub, GitLab, VS Code, Obsidian, Notion, Stack Overflow, Docusaurus, MkDocs, Hugo, Astro Starlight, and nearly every modern Markdown editor.

  10. 10

    Should I use many horizontal rules in one document?

    No. Horizontal rules should separate major sections only. Overusing them can make documentation harder to read and reduce their visual impact.