Markdown Horizontal Rules
Horizontal rules are used to create visual separation in documents, helping to organize content and improve readability. Markdown provides multiple ways to create horizontal rules. This chapter will detail the use of horizontal rules and their application scenarios.
Basic Horizontal Rule Syntax
Syntax Format
Markdown supports three symbols for creating horizontal rules:
All three methods have the same effect:
Syntax Rules
Symbol Quantity
Must use three or more symbols:
Symbol Mixing
Can mix -, *, _:
Effect:
Space Requirements
Symbols can have optional spaces:
Cannot Contain Other Characters
Horizontal rules can only contain -, *, _, cannot mix:
Horizontal Rule Styles
Standard Horizontal Rule
Effect:
Thicker Horizontal Rule
Some editors display *** as a thicker line:
Effect:
Mixed Style
Effect:
Application Scenarios of Horizontal Rules
1. Chapter Separation
2. Topic Switching
3. Topic Separation
4. Content Segmentation
5. Quote and Text Separation
6. Code Example Separation
JavaScript Example
Horizontal Rule Best Practices
1. Consistent Style
Keep consistent horizontal rule style in document:
2. Use Moderately
Don't overuse horizontal rules:
3. Maintain Spacing
Keep blank lines before and after horizontal rules:
4. Coordinate with Other Elements
Coordinate with headings:
Coordinate with quotes:
Difference Between Horizontal Rules and Headings
Horizontal Rules
- Mainly for visual separation
- No semantic hierarchy
- Don't participate in TOC generation
Headings
- Used for content structure
- Clear semantic hierarchy
- Generates TOC
Usage Recommendations
- Chapter switching: Use headings
- Content separation: Use horizontal rules
- Topic change: Use horizontal rule + heading
HTML Horizontal Rule Tags
Basic Usage
Effect:
With Style
Effect:
With Color
Effect:
Dashed Horizontal Rule
Effect:
Dotted Horizontal Rule
Effect:
Custom Thickness
Effect:
Gradient Horizontal Rule
Effect:
Rendering Differences on Different Platforms
GitHub
Renders as thin gray solid line.
GitLab
Renders as medium thickness gray line.
Typora
Supports custom horizontal rule styles, usually renders as medium thickness.
VS Code
When using preview plugin, styles may vary.
Practical Examples
Article Structure
Technical Documentation
Blog Post
Email Template
Special Effects
Centered Horizontal Rule
Effect:
Horizontal Rule with Text
Effect:
Separator Text
Icon Horizontal Rule
Effect:
Horizontal Rule Style Comparison
Common Questions
Q: Horizontal rule not displaying?
A: Check the following:
- Are you using three or more symbols
- Are there blank lines before and after symbols
- Is it on the same line as other content
Q: Different display on different platforms?
A: This is normal, CSS styles may vary across platforms.
Q: How to adjust horizontal rule thickness?
A: Use HTML + CSS:
Q: Can add text in middle of horizontal rule?
A: Standard Markdown doesn't support, implement with HTML.
Summary
This chapter detailed Markdown horizontal rule usage:
- Basic syntax: Create with
-,*,_ - Syntax rules: Three or more symbols
- Application scenarios: Chapter separation, topic switching, content grouping
- Best practices: Consistent style, moderate use, maintain spacing
- HTML extensions: Custom styles, colors, thickness
- Practical applications: Document structure, technical docs, blog posts
Using horizontal rules appropriately will make your document structure clearer and more layered.
Next: Learn Markdown Advanced Tips to improve your Markdown skills.