Markdown Headers
There are two ways to create a header in Markdown: by using hashes or by using underlines.
Hashes
The first option, creating headers with hash signs, is more compact and quicker to type:
1 | # Primary header (similar to HTML H1 tag) |
Underlined headers
Alternatively, you can ‘underline’ your header. It’s a bit more work, but some people prefer it, since it stands out more when looking at the plain text. Note that you can only use this for primary and secondary headers:
1 | Primary header (similar to a HTML H1 tag) |
Emphasis (bold, italic)
There are three ways to emphasize a piece of text that we’ll show in this markdown sheet cheat:
- By making it bolder than the surrounding text
- Using italics
- Or combining *bold and italics*
Make bold text with markdown (strong emphasis)
To create bold text, also called strong emphasis, surround it with two asterisks or two underscores. What you use is a matter of taste.
1 | This is how you create **bold** text |
When converted to HTML or PDF, it will result in: “This is how you create bold text”.
This same, but with underscores:
1 | This is how you create __bold__ text |
Italics with markdown (emphasis)
To create italic text, also called emphasis, support the text with single asterisks or underscores. Again, it’s a matter of tast which one you choose:
1 | This is how you create *italic* text |
When converted to HTML or PDF, it will result in:: “This is how you create italic text.”
The same, but with underscores:
1 | This is how you create _italic_ text |
Combine bold and italics
You can combine both, resulting in *bold italics* text. You can either mix and match, or use triple underscores or triple asterisks, like this:
1 | This is how you create **_bold italics_** text. |
The result when converted to HTML or PDF:
This is how you create bold italics text.
Markdown Lists
You can either create ordered (numbered) lists or unordered lists. Both types of markdown lists look very natural in plain text, as you’ll see in the examples in this markdown sheet cheat.
Ordered lists
To create an ordered list, simple create a text list with numbers, one per line:
1 | 1. Apples |
I numbered the individual items properly, but you don’t have to. In fact, any number will do. However, properly numbering the items will look better in plain text, but it can be a pain sometimes. For example, if you need to add items in the middle of a long list, you need to renumber all of them.
In the end, use whatever suits you best. I tend to number my lists properly since most lists are small anyway and it’s easier on the eyes when looking at the source text.
All markdown converters I know of will convert the following into exactly the same list as the one above:
1 | 1. Apples |
The result:
- Apples
- Bananas
- Peanut butter
Unordered lists
Unordered lists can be made in two ways:
- with asterisks
- or by using dashes
The following lists give an identical output when converted into another document format like HTML or PDF:
1 | - Apples |
and:
1 | * Apples |
Both result in:
- Apples
- Bananas
- Peanut butter
Checklists
Some but not all markdown parsers support checklists. E.g., this works on GitHub and with several markdown plugins for VS Code, for example, but it won’t work within the WordPress Gutenberg editor:
1 | - [x] Apples |
Links in Markdown
You can use Markdown to link to a website or local file. In fact, most markdown converters will automatically convert a URL to a link, but you better not rely on it. In case of doubt, it’s best to try and see what happens in your specific case.
A basic link
1 | This is an inline-style link to our [markdown cheat sheet](/markdown-cheat-sheet) |
This is an inline-style link to our markdown cheat sheet You can also create a relative link: code repo Or an absolute, inline-style link to Google URLs like https://google.com, and sometimes https://google.com or even google.com, get converted to clickable links. Inline-style link with a title attribute to Markdown Land
Reference style links
In addition to regular links, markdown also supports reference-style links. We can define these links somewhere in a file, usually at the bottom, and reference them in the text anywhere.
1 | [This website about Markdown][Case-insensitive reference link to Markdown.land] |
The Python.land tutorial with a numbered link
Or leave it empty and use the link text itself, like this: Python Land.
Text and other Markdown markup, to demonstrate that the reference links can be put anywhere.
Usually, they are placed at the bottom of a document. Because they are reference links, they
won’t show up by themselves. So you won’t see the links below.
This website about Markdown The Python.land tutorial with a numbered link Or leave it empty and use the link text itself, like this: Python Land. Text and other Markdown markup, to demonstrate that the reference links can be put anywhere. Usually, they are placed at the bottom of a document. Because they are reference links, they won’t show up by themselves. So you won’t see the links below.
Tables
I created a separate page explaining all the details about Markdown tables, but for quick reference here’s an example of a Markdown table with the alignment of the price and availability columns:
1 | | Item | Price | # In stock | |
Head over to the Markdown table page for all the details, including column alignment and links to handy table generators to save you time and effort.