Markdown is a lightweight markup language with many advantages, and it’s growing in popularity among writers, editors, etc.
Compared to LaTeX, HTML, or even WYSIWYG editors, Markdown is lightweight, flexible, easy to learn, write, and read.
It’s so simple that you can learn the basics in 60 seconds, yet it’s so powerful that you can use it to write entire books.
If you ever write in the digital world, you should have it in your toolbox.
Here’s a quick example of Markdown in action:
> The _quick_ brown fox, jumped **over** the lazy [dog](https://en.wikipedia.org/wiki/Dog).
gets rendered as:
The quick brown fox, jumped over the lazy dog.
Why is Markdown awesome?
- You can focus on writing without worrying about formatting.
- When you do need powerful formatting, you can do it fairly easily later.
- You can pretty much convert your
.md
file to any other format you can imagine1. HTML, PDF, ePub, or even LaTeX. You name it. - Markdown is just plain text, so it works in almost all editors.2
- Straightforward, super readable, shallow learning curve.
Basic Markdown Formatting
If you are sold at this point, let’s get into some of the basics.
Bold and Italic
Bolding and italicizing text is easy with Markdown:
- Use
**
or__
before and after the text for bold. *
or_
for italic.***
or___
for bold and italic.
**Some bold text**
==> Some bold text
*Some italic text*
==> Some italic text
***Some bold and italic text***
==> Some bold and italic text
Note: There are some non-standard formatting options available, such as ~~
for strikethroughs. However, they are not supported by all Markdown parsers. If you are interested in learning more, check out CommonMark.
Headings
In Markdown, just add #
in front the text to create a heading! The number of hashes indicate the level of the heading. You usually get up to 6 levels of headings.
# Heading 1## Heading 2### Heading 3
Lists
Lists are just so easy in Markdown. To create an unordered list, just add a *
or a -
or a +
as a prefix. For example:
- Markdown is cool- I love Markdown - You can indent too - And more levels- This list is awesome
becomes:
- Markdown is cool
- I love Markdown
- You can indent too
- And more levels
- You can indent too
- This list is awesome
To create an ordered list, add the numbers 1.
2.
3.
and you’re good to go.
For example:
1. Lists2. Are - You can mix unordered and ordered lists 1. That's right3. Fun
becomes:
- Lists
- Are
- You can mix unordered and ordered lists
- That’s right
- You can mix unordered and ordered lists
- Fun
Note that the numbers don’t actually have to be in order. I could have written 1.
, 1.
, 1.
and it would still work. Just make sure you keep the indent consistent.
Links
You can create inline links:
[This is a link to Google](https://google.com "Google")
becomes:
Or you can create reference links:
This line has [a link][1] and [another link][2][1]: https://bobbyy.org[2]: https://google.com
becomes:
This line has a link and another link
Images
Images are very similar to inline links, except you add an exclamation mark (!
) in front.
The syntax is:
![<alt_text>](image_url "<image_title>")
Note that only the image_url
is required. alt_text
and image_title
are optional, but it’s good practice to always include an alt_text
for accessibility.
For example:
![A random image](https://source.unsplash.com/random/1980x1080 "random image title")
becomes:
Blockquotes
For blockquotes, just add a >
in front of the text.
> To be or not to be, that is the question.
becomes:
To be or not to be, that is the question.
Inline Code & Code blocks
Put a backtick (`
) before and after your code to get inline code.
For example, `const x = 1`
becomes const x = 1
.
Put ```
(3 backticks) before and after your code to get a code block.
For example:
```javascriptconst express = require("express")const app = express()const port = 3000app.get("/", (req, res) => { res.send("Hello World!")})app.listen(port, () => { console.log(`Example app listening on port ${port}`)})```
gives you:
What next?
Why not write something with Markdown right now? Try it out with CommonMark’s dingus.
There are also several markup languages built on top of Markdown, such as GitHub Flavored Markdown and CommonMark. If you want to learn more, I recommend checking out this page.