Markdown allows you to create headers of various levels using the hash symbol (#). The number of hashes at the beginning of a line indicates the header level.
Markdown supports up to six header levels, from h1 to h6.
# Level 1 Header
## Level 2 Header
### Level 3 Header
#### Level 4 Header
#### Level 5 Header
#### Level 6 Header
This renders as:
Spaces After Hashes
There must be a space between the hashes and the header text for it to render correctly.
Incorrect example:
#Incorrect Header
This does not render as a header.
#Incorrect header
Correct example:
# Correct Header
Now it does,
This is a very common mistake that can drive you crazy at some point, especially if your editor doesn’t differentiate headers by colors.
Differences Between Headers
Headers vs. Bold Text
It’s important not to confuse headers with bold text. While headers structure the content, bold text is used to highlight specific parts within the text.
Bold text example:
**This is bold text.**
This renders as:
This is bold text.
They might seem like the same functionality but they are not. Headers delimit areas, sections, or parts of a document. While bold text highlights a part of the content for being especially relevant.
Best Practices Tips
Consistency in Header Levels: Maintain a coherent structure by using header levels hierarchically. Start with h1 for the main title, h2 for main sections, h3 for subsections, and so on.
Clarity and Readability: Use headers to divide content into clear and readable sections.
Descriptive Headers: Ensure that headers clearly describe the content of the section.
Don’t overuse headers: Avoid excessive use of header levels. Generally, it’s not necessary to use h5 or h6 unless the document is very complex.
