Skip to content

Latest commit

 

History

History
574 lines (367 loc) · 12.5 KB

markdown.md

File metadata and controls

574 lines (367 loc) · 12.5 KB

Markdown Language

Cheatsheet for .md syntax


Overview

Nearly all Markdown applications support the basic syntax outlined in the original Markdown design document. There are minor variations and discrepancies between Markdown processors — those are noted inline wherever possible.


Headings

To create a heading, add number signs (#) in front of a word or phrase. The number of number signs you use should correspond to the heading level. For example, to create a heading level three (<h3>), use three number signs (e.g., ### My Header).


Heading level 1

Heading level 2

Heading level 3

Heading level 4

Heading level 5
Heading level 6

Heading Best Practices

Markdown applications don’t agree on how to handle a missing space between the number signs (#) and the heading name. For compatibility, always put a space between the number signs and the heading name.

✅ Do this: _# Heading_
❌ Don't do this: _#Heading_



Paragraphs

To create paragraphs, use a blank line to separate one or more lines of text.

Note: If you need to indent paragraphs in the output, see the section on how to indent (tab). Don't put tabs or spaces in front of your paragraphs, keep them left-aligned.


✅ Do this: 'Hello World'
❌ Don't do this: ' Hello World'



Line Breaks

To create a line break or new line (<br>), end a line with two or more spaces, and then type return.


Line Break Best Practices

You can use two or more spaces (commonly referred to as “trailing whitespace”) for line breaks in nearly every Markdown application, but it’s controversial. It’s hard to see trailing whitespace in an editor, and many people accidentally or intentionally put two spaces after every sentence. For this reason, you may want to use something other than trailing whitespace for line breaks. If your Markdown application supports HTML, you can use the <br> HTML tag.

For compatibility, use trailing white space or the <br> HTML tag at the end of the line.


✅ Do this: trailing 2 spaces__ or <br>
❌ Don't do this: ending sentence with \



Emphasis

You can add emphasis by making text bold or italic.


Bold

To bold text, add two asterisks or underscores before and after a word or phrase. To bold the middle of a word for emphasis, add two asterisks without spaces around the letters.

Bold Best Practices

Markdown applications don’t agree on how to handle underscores in the middle of a word. For compatibility, use asterisks to bold the middle of a word for emphasis.


Italic

To italicize text, add one asterisk or underscore before and after a word or phrase. To italicize the middle of a word for emphasis, add one asterisk without spaces around the letters.


Italic Best Practices

Markdown applications don’t agree on how to handle underscores in the middle of a word. For compatibility, use asterisks to italicize the middle of a word for emphasis.

✅ Do this: A*cat*meow --> Acatmeow
❌ Don't do this: A_cat_meow --> A_cat_meow


Bold and Italic

To emphasize text with bold and italics at the same time, add three asterisks or underscores before and after a word or phrase. To bold and italicize the middle of a word for emphasis, add three asterisks without spaces around the letters.

Note: The order of the em and strong tags might be reversed depending on the Markdown processor you're using.


Bold and Italic Best Practices

Markdown applications don’t agree on how to handle underscores in the middle of a word. For compatibility, use asterisks to bold and italicize the middle of a word for emphasis.

✅ Do this: This is really***very***important text. --> This is really**veryimportant text
❌ Don't do this: This is really___very___important text. --> This is really
very**important text.



Blockquotes

To create a blockquote, add a > in front of a paragraph.

Example: > I am a blockquote.

Output:

I am a blockquote.


Blockquotes with Multiple Paragraphs

Blockquotes can contain multiple paragraphs. Add a > on the blank lines between the paragraphs.

> Dorothy followed her through many of the beautiful rooms in her castle.
>
> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.

Output:

Dorothy followed her through many of the beautiful rooms in her castle.

The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.


Nested Blockquotes

Blockquotes can be nested. Add a >> in front of the paragraph you want to nest.

> Dorothy followed her through many of the beautiful rooms in her castle.
>
> > The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.

Output:

Dorothy followed her through many of the beautiful rooms in her castle.

The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.


Blockquotes with Other Elements

Blockquotes can contain other Markdown formatted elements. Not all elements can be used — you’ll need to experiment to see which ones work.

> #### The quarterly results look great!
>
> -   Revenue was off the chart.
> -   Profits were higher than ever.
>
>     _Everything_ is going according to **plan**.

Output:

The quarterly results look great!

  • Revenue was off the chart.

  • Profits were higher than ever.

    Everything is going according to plan.


Blockquotes Best Practices

For compatibility, put blank lines before and after blockquotes.

✅ Do this:

Try to put a blank line before...

> This is a blockquote

...and after a blockquote. Without blank lines, this might not look right.

❌ Don't do this:

Without blank lines, this might not look right.

> This is a blockquote
> Don't do this!


Ordered Lists

To create an ordered list, add line items with numbers followed by periods. The numbers don’t have to be in numerical order, but the list should start with the number one.


✅ Do this:

1. First item
2. Second item
3. Third item
4. Fourth item
    1. Tab or 4 spaces, use '1.' to start at 1.
    2. Doesn't matter what number you use afterwards
    3. It will count in order
5. Then stop nesting by removing tab / space

Output:

  1. First item
  2. Second item
  3. Third item
  4. Fourth item
    1. Tab or 4 spaces, use '1.' to start at 1.
    2. Doesn't matter what number you use afterwards
    3. It will count in order
  5. Then stop nesting by removing tab / space

✅ Or do this:

<ol>
    <li>First item</li>
    <li>Second item</li>
    <ol>
        <li>First nested list item</li>
        <li>Second nested list item</li>
    </ol>
    <li>Third item</li>
    <li>Fourth item</li>
</ol>

Output:

  1. First item
  2. Second item
    1. First nested list item
    2. Second nested list item
  3. Third item
  4. Fourth item

Ordered List Best Practices

CommonMark and a few other lightweight markup languages let you use a parenthesis ()) as a delimiter (e.g., 1) First item), but not all Markdown applications support this, so it isn’t a great option from a compatibility perspective. For compatibility, use periods only.


✅ Do this:

1. First item
2. Second item

❌ Don't do this:

1. First item
2. Second item

Unordered Lists

To create an unordered list, add dashes (-), asterisks (*), or plus signs (+) in front of line items. Indent one or more items to create a nested list.

✅ Do this:

-   First item
-   Second item
-   Third item
-   Fourth item
    -   Tab or 4 spaces, use '1.' to start at 1
    -   Doesn't matter what number you use afterwards
    -   It will count in order
-   Then stop nesting by removing tab / space

Output:

  • First item
  • Second item
  • Third item
  • Fourth item
    • Tab or 4 spaces to start nesting another list
    • Second item
  • Then stop nesting by removing tab / space

✅ Or do this:

<ul>
    <li>First item</li>
    <li>Second item</li>
    <ul>
        <li>First nested list item</li>
        <li>Second nested list item</li>
    </ul>
    <li>Third item</li>
    <li>Fourth item</li>
</ul>

Output:

  • First item
  • Second item
    • First nested list item
    • Second nested list item
  • Third item
  • Fourth item

Starting Unordered List Items With Numbers

If you need to start an unordered list item with a number followed by a period, you can use a backslash () to escape the period.

-   1968\. A great year!
-   I think 1969 was second best.

Or

<ul>
    <li>1968. A great year!</li>
    <li>I think 1969 was second best.</li>
</ul>

Output:

  • 1968. A great year!
  • I think 1969 was second best.

Unordered List Best Practices

Markdown applications don’t agree on how to handle different delimiters in the same list. For compatibility, don’t mix and match delimiters in the same list — pick one and stick with it.


✅ Do this:

-   First item
-   Second item
-   Third item
-   Fourth item

Output:

  • First item
  • Second item
  • Third item
  • Fourth item

❌ Don't do this:

+ First item
* Second item
- Third item
* Fourth item


Linking Images

To add a link to an image, enclose the Markdown for the image in brackets, and then add the link in parentheses. You can also then add a space after the URL and include a description that will appear when the user hovers over it.


Example:

![A photo of a mountain](../img/linked_img_sample.png 'Shiprock, New Mexico by Beau Rogers')

Output:
A photo of a mountain



Horizontal Rules

To create a horizontal rule, use three or more asterisks (***), dashes (---), or underscores (___) on a line by themselves. The rendered output of all three looks identical:


Horizontal Rule Best Practices

For compatibility, put blank lines before and after horizontal rules.


✅ Do this:

Try to put a blank line before...

---

...and after a horizontal rule.

❌ Don't do this:

## Without blank lines, this would be a heading.

Don't do this!


Links

To create a link, enclose the link text in brackets (e.g., [Duck Duck Go]) and then follow it immediately with the URL in parentheses.

My favorite search engine is [Duck Duck Go](https://duckduckgo.com)

Output: My favorite search engine is Duck Duck Go.



You can use links to jump to a section in your current file or even a section in a local file as well using a similar syntax. You'd just need to give an ID to the part you want to jump to and provide that same ID in the file path.

[Linking to the breakpoints section of css.md](../css.md#breakpoints)

Output: Linking to the breakpoints section of css.md



Adding Titles

You can optionally add a title for a link. This will appear as a tooltip when the user hovers over the link. To add a title, enclose it in quotation marks after the URL.

My favorite search engine is [Duck Duck Go](https://duckduckgo.com 'The best search engine for privacy').

Output: My favorite search engine is Duck Duck Go.



URLs and Email Addresses

To quickly turn a URL or email address into a link, enclose it in angle brackets.


Example:

<https://www.markdownguide.org>
<fake@example.com>

Output: https://www.markdownguide.org | fake@example.com



Characters you can escape

Characters you can escape



Resources


For a more complete guide with more examples, visit: https://www.markdownguide.org/basic-syntax/ (Main source)

or

https://www.markdownguide.org/extended-syntax/#:~:text=There%20are%20two%20ways%20to,text%2C%20or%20type%20emoji%20shortcodes (Going a bit further)