Markdown Guide
Markdown Guide
Markdown Guide
Matt Cone
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
Where to Get This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
How to Read This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
Beginner Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
Syntax Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
Asides . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
Quirks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
Contributing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
Reporting Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv
1. Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Kicking the Tires . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
How Markdown Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3. Basic Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Headings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
CONTENTS
Alternate Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Paragraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Line Breaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Emphasis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Bold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Italic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Bold and Italic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Blockquotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Blockquotes with Multiple Paragraphs . . . . . . . . . . . . . . . . . . . 16
Nested Blockquotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Blockquotes with Other Elements . . . . . . . . . . . . . . . . . . . . . . 17
Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Ordered Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Unordered Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Adding Elements in Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Escaping Tick Marks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Code Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Horizontal Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Adding Titles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
URLs and Email Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Formatting Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Reference-style Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Escaping Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Characters You Can Escape . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4. Extended Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Lightweight Markup Languages . . . . . . . . . . . . . . . . . . . . . . . 37
Markdown Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Formatting Text in Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Escaping Pipe Characters in Tables . . . . . . . . . . . . . . . . . . . . . 41
CONTENTS
5. Cheat Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Basic Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Extended Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
visitors a day by early 2018. At that point, it occurred to me that people might also
appreciate the Markdown Guide in book format.
I hope you enjoy reading this book as much as I’ve enjoyed writing it. Above all, I
hope it helps you write using Markdown, and I hope using Markdown makes you a
better writer.
Beginner Resources
The first two chapters of this book are designed exclusively for readers who are new
to Markdown. Getting Started provides a quick introduction to Markdown. It shows
you how to get going quickly with the Dillinger online Markdown editor, and it sheds
light on some of the stuff going on behind the scenes.
Doing Things With Markdown talks about what you can create using Markdown. It
also presents some the applications you can use to write using Markdown.
Syntax Examples
To help you learn how to write using Markdown, I’ve provided three sections for
every syntax element in the chapters on basic and extended syntax:
Introduction iii
To learn more about the Markdown to HTML conversion, see the section on how
Markdown works.
Asides
Extra bits of information are displayed with an “i” icon next to them, like this:
Tips are displayed with a key icon next to them, like this:
Quirks
Some of the Markdown and HTML code samples in this book “wrap” to the next line.
In the situations where that happens, you’ll see a \ at the end of the first line of the
code block. That \ isn’t actually part of the code. It’s displayed there to indicate that
the next line of the code block is actually part of the same line.
Contributing
This book is an open-source project, and your contributions are welcome. The
repository is hosted on GitHub. See the README for instructions and guidelines.
Introduction iv
Reporting Issues
Find something wrong? Create an issue on GitHub and I’ll fix it as soon as possible.
Thank you!
Acknowledgements
I’m eternally grateful to Reem and our children, Finn and Simon. This book wouldn’t
exist without their love and support.
I greatly appreciate the help of AK Molteni, Gaylin Walli, Juan Torrez, Diana Lynch,
and my parents, Steve Cone and Kathie Lathan, who were sounding boards for the
website and book. Thanks to Josh Ellingson for creating the amazing, jaw-dropping
artwork on the cover. Last, but certainly not least, I’d like to thank you and everyone
else who has read and contributed to the Markdown Guide. You’ve not only made
this book possible, you’ve made it better!
1. Getting Started
Markdown is a lightweight markup language that you can use to add formatting
elements to plaintext text documents. Created by John Gruber in 2004, Markdown is
now one of the world’s most popular markup languages.
Using Markdown is different than using a WYSIWYG editor. In an application like
Microsoft Word, you click buttons to format words and phrases, and the changes
are visible immediately. Markdown isn’t like that. When you create a Markdown-
formatted file, you add Markdown syntax to the text to indicate which words and
phrases should look different.
For instance, to denote a heading, you add a number sign before it (e.g., # Heading
One). Or to make a phrase bold, you add two asterisks before and after it (e.g., **this
text is bold**). It may take a while to get used to seeing Markdown syntax in
your text, especially if you’re accustomed to WYSIWYG applications. The screenshot
below shows a Markdown file displayed in the Atom text editor.
You can add Markdown formatting elements to a plaintext file using a text editor
application. Or you can use one of the many Markdown applications for macOS,
Windows, Linux, iOS, and Android operating systems. There are also several web-
based applications specifically designed for writing in Markdown.
Depending on the application you use, you may not be able to preview the formatted
document in real time. But that’s okay. According to Gruber, Markdown syntax is
designed to be readable and unobtrusive, so the text in Markdown files can be read
even if it isn’t rendered.
The Dillinger Markdown editor is a free and easy way to get started with Markdown.
You’ll probably want to keep the Dillinger website open as you read through this
guide. That way you can try the syntax as you learn about it. After you’ve become
familiar with Markdown, you may want to use a Markdown application that can be
installed on your desktop computer or mobile device.
.md or .markdown extension. But then what? How is your Markdown-formatted file
converted into HTML or a print-ready document?
The short answer is that you need a Markdown application capable of processing the
Markdown file. There are lots of applications available — everything from simple
scripts to desktop applications that look like Microsoft Word. Despite their visual
differences, all of the applications do the same thing. Like Dillinger, they all convert
Markdown-formatted text to HTML so it can be displayed in web browsers.
Markdown applications use something called a Markdown processor (also commonly
referred to as a “parser” or an “implementation”) to take the Markdown-formatted
text and output it to HTML format. At that point, your document can be viewed
in a web browser or combined with a style sheet and printed. You can see a visual
representation of this process below.
From your perspective, the process will vary somewhat depending on the application
you use. For example, Dillinger essentially combines steps 1-3 into a single, seamless
interface — all you have to do is type in the left pane and the rendered output
Getting Started 6
magically appears in the right pane. But if you use other tools, like a text editor
with a static website generator, you’ll find that the process is much more visible.
Additional Resources
There are lots of other resources you can use to learn Markdown. Here are a few of
my favorites:
Websites
Markdown was designed for the web, so it should come as no surprise that there are
plenty of applications specifically designed for creating website content.
If you’re looking for the simplest possible way to create a website with Markdown
files, check out blot.im and smallvictori.es. After you sign up for one of these services,
they create a Dropbox folder on your computer. Just drag and drop your Markdown
files into the folder and — poof! — they’re on your website. It couldn’t be easier.
If you’re familiar with HTML, CSS, and version control, check out Jekyll, a popular
static site generator that takes Markdown files and builds an HTML website. One
advantage to this approach is that GitHub Pages provides free hosting for Jekyll-
generated websites. If Jekyll isn’t your cup of tea, just pick one of the many other
static site generators available.
I used Jekyll to create the Markdown Guide website. You can view the
source code on GitHub.
If you’d like to use a content management system (CMS) to power your website, take
a look at Ghost. It’s a free and open-source blogging platform with a nice Markdown
Doing Things With Markdown 8
Documents
Markdown doesn’t have all the bells and whistles of word processors like Microsoft
Word, but it’s good enough for creating basic documents like assignments and letters.
You can use a Markdown document authoring application to create and export
Markdown-formatted documents to PDF or HTML file format. The PDF part is key,
because once you have a PDF document, you can do anything with it — print it,
email it, or upload it to a website.
Here are some Markdown document authoring applications we recommend:
Notes
In nearly every way, Markdown is the ideal syntax for taking notes. Sadly, Evernote
and OneNote, two of the most popular note applications, don’t currently support
Markdown. The good news is that several other note applications do support
Markdown:
Doing Things With Markdown 9
If you can’t part with Evernote, check out Marxico, a subscription-based Markdown
editor for Evernote, or use Markdown Here with the Evernote website.
Books
Looking to self-publish a novel? Try Leanpub, a service that takes your Markdown-
formatted files and turns them into an electronic book. Leanpub outputs your book
in PDF, EPUB, and MOBI file format. If you’d like to create paperback copies of
your book, you can upload the PDF file to another service such as Kindle Direct
Publishing or CreateSpace. To learn more about writing and self-publishing a book
using Markdown, read this blog post.
Presentations
Believe it or not, you can generate presentations from Markdown-formatted files.
Creating presentations in Markdown takes a little getting used to, but once you get
the hang of it, it’s a lot faster and easier than using an application like PowerPoint or
Keynote. Remark (GitHub project) is a popular browser-based Markdown slideshow
tool, as is Cleaver (GitHub project). If you use a Mac and would prefer to use an
application, check out Deckset or Marked.
Email
If you send a lot of email and you’re tired of the formatting controls available on
most email provider websites, you’ll be happy to learn there’s an easy way to write
email messages using Markdown. Markdown Here is a free and open-source browser
extension that converts Markdown-formatted text into HTML that’s ready to send.
Doing Things With Markdown 10
Documentation
Markdown is a natural fit for technical documentation. Companies like GitHub are
increasingly switching to Markdown for their documentation — check out their blog
post about how they migrated their Markdown-formatted documentation to Jekyll.
If you write documentation for a product or service, take a look at these handy tools:
• Read the Docs can generate a documentation website from your open source
Markdown files. Just connect your GitHub repository to their service and push
— Read the Docs does the rest. They also have a service for commercial entities.
• MkDocs is a fast and simple static site generator that’s geared towards building
documentation. The source files are written in Markdown and organized with a
single YAML configuration file. MkDocs has several built in themes, including
a port of the Read the Docs documentation theme. One of the newest themes is
MkDocs Material, which incorporates elements of Google’s Material Design.
• Docusaurus is a static site generator designed exclusively for creating docu-
mentation websites. It supports translations, search, and versioning.
• VuePress is a static site generator powered by Vue and optimized for writing
technical documentation.
• Jekyll was mentioned earlier in the section on websites, but it’s also a good
option for generating a documentation website from Markdown files. If you go
this route, be sure to check out the Jekyll documentation theme.
3. Basic Syntax
Nearly all Markdown applications support the basic syntax outlined in John Gruber’s
original design document. There are minor variations and discrepancies between
Markdown processors — those are noted inline wherever possible.
Using Markdown doesn’t mean that you can’t also use HTML. You can
add HTML tags to any Markdown file. This is helpful if you prefer certain
HTML tags to Markdown syntax. For example, some people find that it’s
easier to use HTML tags for images.
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).
Markdown HTML
# Heading level 1 <h1>Heading level 1</h1>
## Heading level 2 <h2>Heading level 2</h2>
### Heading level 3 <h3>Heading level 3</h3>
#### Heading level 4 <h4>Heading level 4</h4>
##### Heading level 5 <h5>Heading level 5</h5>
###### Heading level 6 <h6>Heading level 6</h6>
Alternate Syntax
Alternatively, on the line below the text, add any number of == characters for heading
level 1 or -- characters for heading level 2.
Basic Syntax 12
Markdown HTML
Heading level 1 <h1>Heading level 1</h1>
===============
Paragraphs
To create paragraphs, use a blank line to separate one or more lines of text. You
should not indent paragraphs with spaces or tabs.
Markdown
HTML
Line Breaks
To create a line break (<br>), end a line with two or more spaces, and then type
return.
Basic Syntax 13
Markdown
HTML
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.
Markdown
HTML
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.
Markdown
1 ***Important*** text.
2
3 ___Important___ text.
4
5 __*Important*__ text.
6
7 **_Important_** text.
1 <strong><em>Important</em></strong> text.
Blockquotes
To create a blockquote, add a > in front of a paragraph.
Markdown
HTML
1 <blockquote>
2 <p>Dorothy followed her through many rooms.</p>
3 </blockquote>
HTML
1 <blockquote>
2 <p>This the first paragraph.</p>
3 <p>And this is the second paragraph.</p>
4 </blockquote>
Nested Blockquotes
Blockquotes can be nested. Add a >> in front of the paragraph you want to nest.
Basic Syntax 17
Markdown
HTML
1 <blockquote>
2 <p>This the first paragraph.</p>
3 <blockquote>
4 <p>And this is the nested paragraph.</p>
5 </blockquote>
6 </blockquote>
HTML
1 <blockquote>
2 <h5>The quarterly results look great!</h5>
3 <ul>
4 <li>Revenue was off the chart.</li>
5 <li>Profits were higher than ever.</li>
6 </ul>
7 <p><em>Everything</em> is going <strong>well</strong>.</p>
8 </blockquote>
Lists
You can organize items into ordered and unordered lists.
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.
Basic Syntax 19
Markdown
1 1. First item
2 2. Second item
3 3. Third item
4 4. Fourth item
5
6 1. First item
7 1. Second item
8 1. Third item
9 1. Fourth item
10
11 1. First item
12 8. Second item
13 3. Third item
14 5. Fourth item
1. First item
2. Second item
3. Third item
4. Fourth item
To nest line items in an ordered list, indent the items four spaces or one tab.
Basic Syntax 20
Markdown
1 1. First item
2 2. Second item
3 3. Third item
4 1. Indented item
5 2. Indented item
6 4. Fourth item
HTML
1 <ol>
2 <li>First item</li>
3 <li>Second item</li>
4 <li>Third item
5 <ol>
6 <li>Indented item</li>
7 <li>Indented item</li>
8 </ol>
9 </li>
10 <li>Fourth item</li>
11 </ol>
1. First item
2. Second item
3. Third item
1. Indented item
2. Indented item
4. Fourth item
Unordered Lists
To create an unordered list, add dashes (-), asterisks (*), or plus signs (+) in front of
line items.
Basic Syntax 21
Markdown
1 - First item
2 - Second item
3 - Third item
4 - Fourth item
5
6 * First item
7 * Second item
8 * Third item
9 * Fourth item
10
11 + First item
12 * Second item
13 - Third item
14 + Fourth item
• First item
• Second item
• Third item
• Fourth item
To nest line items in an unordered list, indent the items four spaces or one tab.
Basic Syntax 22
Markdown
1 - First item
2 - Second item
3 - Third item
4 - Indented item
5 - Indented item
6 - Fourth item
HTML
1 <ul>
2 <li>First item</li>
3 <li>Second item</li>
4 <li>Third item
5 <ul>
6 <li>Indented item</li>
7 <li>Indented item</li>
8 </ul>
9 </li>
10 <li>Fourth item</li>
11 </ul>
• First item
• Second item
• Third item
– Indented item
– Indented item
• Fourth item
Paragraphs
Basic Syntax 23
Markdown
HTML
1 <ul>
2 <li><p>This is the first list item.</p></li>
3 <li><p>Here's the second list item.</p>
4 <p>I need to add another paragraph below the second list item.</p>
5 </li>
6 <li><p>And here's the third list item.</p></li>
7 </ul>
Blockquotes
Basic Syntax 24
Markdown
HTML
1 <ul>
2 <li><p>This is the first list item.</p></li>
3 <li><p>Here's the second list item.</p>
4 <blockquote>
5 <p>A blockquote would look great here.</p>
6 </blockquote>
7 </li>
8 <li><p>And here's the third list item.</p>
9 </li>
10 </ul>
Code Blocks
Code blocks are normally indented four spaces or one tab. When they’re in a list,
indent them eight spaces or two tabs.
Basic Syntax 25
Markdown
HTML
1 <ol>
2 <li><p>Open the file.</p></li>
3 <li><p>Find the following code block on line 21:</p>
4 <pre><code><html>
5 <head>
6 <title>Test</title>
7 </head>
8 </code></pre>
9 </li>
10 <li><p>Update the title to match the name of your website.</p></li>
11 </ol>
1 <html>
2 <head>
3 <title>Test</title>
4 </head>
Images
Markdown
HTML
1 <ol>
2 <li><p>Open the file containing Tux, the Linux mascot.</p></li>
3 <li>
4 <p>Marvel at its beauty.</p>
5 <p><img src="images/tux.png" alt="Tux" /></p>
6 </li>
7 <li><p>Close the file.</p></li>
8 </ol>
Tux
3. Close the file.
Code
To denote a word or phrase as code, enclose it in tick marks (`).
Markdown
HTML
Markdown
HTML
Code Blocks
To create code blocks, indent every line of the block by at least four spaces or one
tab.
Markdown
1 <html>
2 <head>
3 </head>
4 </html>
HTML
1 <pre>
2 <code>
3 <html>
4 <head>
5 </head>
6 </html>
7 </code>
8 </pre>
1 <html>
2 <head>
3 </head>
4 </html>
To create code blocks without indenting lines, use fenced code blocks.
Horizontal Rules
To create a horizontal rule, use three or more asterisks (***), dashes (---), or
underscores (___) on a line by themselves.
Markdown
1 ***
2
3 ---
4
5 _________________
HTML
1 <hr />
2
3 <hr />
4
5 <hr />
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 (e.g., (https://duckduckgo.com)).
Markdown
1 Use [Duck Duck Go](https://duckduckgo.com).
HTML
1 <p>Use <a href="https://duckduckgo.com">Duck Duck Go</a>.</p>
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 parentheses after the URL.
Markdown
1 Use [Duck Duck Go](https://duckduckgo.com "My search engine!").
HTML
1 <p>Use <a href="https://duckduckgo.com" title="My search engine!">Duck \
2 Duck Go</a>.</p>
Markdown
1 <https://eff.org>
2 <[email protected]>
HTML
1 <a href="https://eff.org">https://eff.org</a>
2 <a href="mailto:[email protected]">[email protected]</a>
Formatting Links
To emphasize links, add asterisks before and after the brackets and parentheses.
Markdown
1 I love supporting **[EFF](https://eff.org)**.
2 This is the *[EFF](https://eff.org)*.
HTML
1 <p>I love supporting <strong><a href="https://eff.org">EFF</a></strong>.
2 This is the <em><a href="https://eff.org">EFF</a></em>.</p>
Reference-style Links
Reference-style links are a special kind of link that make URLs easier to display and
read in Markdown. Reference-style links are constructed in two parts: the part you
keep inline with your text and the part you store somewhere else in the file to keep
the text easy to read.
Basic Syntax 32
The first part of a reference-style link is formatted with two sets of brackets. The
first set of brackets surrounds the text that should appear linked. The second set of
brackets displays a label used to point to the link you’re storing elsewhere in your
document.
Although not required, you can include a space between the first and second set of
brackets. Also, the label in the second set of brackets is not case sensitive and can
include letters, numbers, spaces, or punctuation.
This means the following example formats are all roughly equivalent for the first
part of the link:
• [hobbit-hole][1]
• [hobbit-hole] [1]
• [hobbit-hole][a]
• [hobbit-hole][A]
The second part of a reference-style link is formatted with the following attributes:
1. The label, in brackets, followed immediately by a colon and at least one space
(e.g., [label]: ).
2. The URL for the link, which you can optionally enclose in angle brackets.
3. The optional title for the link, which you can enclose in double quotes, single
quotes, or parentheses.
This means the following example formats are all roughly equivalent for the second
part of the link:
• [hobbit-hole]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle
• [hobbit-hole]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle "Hobbit
lifestyles"
• [hobbit-hole]: https://en.wikipedia.org/wiki/Hobbit#Lifestyle 'Hobbit
lifestyles'
Basic Syntax 33
You can place this second part of the link anywhere in your Markdown document.
Some people place them immediately after the paragraph in which they appear while
other people place them at the end of the document (like endnotes or footnotes).
Say you add a URL as a standard URL link to a paragraph and it looks like this in
Markdown:
Markdown
1 In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet h\
2 ole, filled with the ends of worms and an oozy smell, nor yet a dry, ba\
3 re, sandy hole with nothing in it to sit down on or to eat: it was a [h\
4 obbit-hole](https://en.wikipedia.org/wiki/Hobbit#Lifestyle "Hobbit life\
5 styles"), and that means comfort.
Markdown
1 In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet h\
2 ole, filled with the ends of worms and an oozy smell, nor yet a dry, ba\
3 re, sandy hole with nothing in it to sit down on or to eat: it was a [h\
4 obbit-hole][1], and that means comfort.
5
6 [1]: <https://en.wikipedia.org/wiki/Hobbit#Lifestyle> "Hobbit lifestyle\
7 s"
In both instances above, the HTML for the link would be identical:
Basic Syntax 34
HTML
Images
To add an image, add an exclamation mark (!), followed by alt text in brackets, and
the path or URL to the image asset in parentheses. You can optionally add a title after
the URL in the parentheses.
Markdown
HTML
Escaping Characters
To display a literal character that would otherwise be used to format text in a
Markdown document, add a backslash (\) in front of the character.
Markdown
HTML
Character Name
\ backslash
` tickmark
* asterisk
_ underscore
{} curly braces
[] brackets
() parentheses
# pound sign
+ plus sign
- minus sign (hyphen)
. dot
! exclamation mark
4. Extended Syntax
The basic syntax outlined in John Gruber’s original design document added many
of the elements needed on a day-to-day basis, but it wasn’t enough for some people.
That’s where extended syntax comes in.
Several individuals and organizations took it upon themselves to extend the basic
syntax by adding additional elements like tables, code blocks, syntax highlight-
ing, URL auto-linking, and footnotes. These elements can be enabled by using a
lightweight markup language that builds upon the basic Markdown syntax, or by
adding an extension to a compatible Markdown processor.
Availability
Extended syntax isn’t available in all Markdown applications. You’ll need to check
whether or not the lightweight markup language your application is using supports
extended syntax. If it doesn’t, it may still be possible to enable extensions in your
Markdown processor.
• CommonMark
• GitHub Flavored Markdown (GFM)
• Markdown Extra
• MultiMarkdown
Extended Syntax 38
Markdown Processors
There are dozens of Markdown processors available. Many of them allow you to add
extensions that enable extended syntax. Check your processor’s documentation for
more information.
Tables
To add a table, use three or more hyphens (---) to create each column’s header, and
use pipes (|) to separate each column. You can optionally add pipes on either end of
the table.
Markdown
1 | Syntax | Description |
2 | ----------- | ----------- |
3 | Header | Title |
4 | Paragraph | Text |
HTML
1 <table>
2 <thead>
3 <tr class="header">
4 <th>Syntax</th>
5 <th>Description</th>
6 </tr>
7 </thead>
8 <tbody>
9 <tr class="odd">
10 <td>Header</td>
11 <td>Title</td>
12 </tr>
13 <tr class="even">
14 <td>Paragraph</td>
15 <td>Text</td>
Extended Syntax 39
16 </tr>
17 </tbody>
18 </table>
Syntax Description
Header Title
Paragraph Text
Cell widths can vary, as shown below. The rendered output will look the same.
Markdown
1 | Syntax | Description |
2 | --- | ----------- |
3 | Header | Title |
4 | Paragraph | Text |
Creating tables with hyphens and pipes can be tedious. To speed up the
process, try using the Markdown Tables Generator. Build a table using the
graphical interface, and then copy the generated Markdown-formatted text
into your file.
Alignment
You can align text in the columns to the left, right, or center by adding a colon (:) to
the left, right, or on both side of the hyphens within the header row.
Extended Syntax 40
Markdown
HTML
1 <table>
2 <thead>
3 <tr class="header">
4 <th style="text-align: left;">Syntax</th>
5 <th style="text-align: center;">Description</th>
6 <th style="text-align: right;">Test Text</th>
7 </tr>
8 </thead>
9 <tbody>
10 <tr class="odd">
11 <td style="text-align: left;">Header</td>
12 <td style="text-align: center;">Title</td>
13 <td style="text-align: right;">Here’s this</td>
14 </tr>
15 <tr class="even">
16 <td style="text-align: left;">Paragraph</td>
17 <td style="text-align: center;">Text</td>
18 <td style="text-align: right;">And more</td>
19 </tr>
20 </tbody>
21 </table>
1 ```
2 {
3 "firstName": "John",
4 "lastName": "Smith",
5 "age": 25
6 }
7 ```
Extended Syntax 42
HTML
1 <pre>
2 <code>
3 {
4 "firstName": "John",
5 "lastName": "Smith",
6 "age": 25
7 }
8 </code>
9 </pre>
1 {
2 "firstName": "John",
3 "lastName": "Smith",
4 "age": 25
5 }
Syntax Highlighting
Many Markdown processors support syntax highlighting for fenced code blocks. This
feature allows you to add color highlighting for whatever language your code was
written in. To add syntax highlighting, specify a language next to the tick marks
before the fenced code block.
Extended Syntax 43
Markdown
1 ```json
2 {
3 "firstName": "John",
4 "lastName": "Smith",
5 "age": 25
6 }
7 ```
HTML
1 <pre>
2 <code class="language-json">
3 {
4 "firstName": "John",
5 "lastName": "Smith",
6 "age": 25
7 }
8 </code>
9 </pre>
1 {
2 "firstName": "John",
3 "lastName": "Smith",
4 "age": 25
5 }
Footnotes
Footnotes allow you to add notes and references without cluttering the body of the
document. When you create a footnote, a superscript number with a link appears
Extended Syntax 44
where you added the footnote reference. Readers can click the link to jump to the
content of the footnote at the bottom of the page.
To create a footnote reference, add a caret and an identifier inside brackets ([^1]).
Identifiers can be numbers or words, but they can’t contain spaces or tabs. Identifiers
only correlate the footnote reference with the footnote itself — in the output,
footnotes are numbered sequentially.
Add the footnote using another caret and number inside brackets with a colon
and text ([^1]: My footnote.). You don’t have to put footnotes at the end of the
document. You can put them anywhere except inside other elements like lists, block
quotes, and tables.
Markdown
HTML
1 <p>
2 Here’s a simple footnote,<a href="#fn1" class="footnote-ref" id="fnre\
3 f1"><sup>1</sup></a> and here’s a longer one.<a href="#fn2" class="foot\
4 note-ref" id="fnref2"><sup>2</sup></a>
5 </p>
6 <section class="footnotes">
7 <hr />
8 <ol>
9 <li id="fn1"><p>This is the first footnote.<a href="#fnref1" class=\
Extended Syntax 45
10 "footnote-back">↩︎</a></p></li>
11 <li id="fn2">
12 <p>Here’s one with multiple paragraphs and code.</p>
13 <p>Indent paragraphs to include them in the footnote.</p>
14 <p><code>{ my code }</code></p>
15 <p>Add as many paragraphs as you like.<a href="#fnref2" class="fo\
16 otnote-back">↩︎</a></p>
17 </li>
18 </ol>
19 </section>
Heading IDs
Many Markdown processors support custom IDs for headings — some Markdown
processors automatically add them. Adding custom IDs allows you to link directly
to headings and modify them with CSS. To add a custom heading ID, enclose the
custom ID in curly braces on the same line as the heading.
Markdown
HTML
1 [Heading IDs](#heading-ids)
HTML
Other websites can link to the heading by adding the custom heading ID to the full
URL of the webpage (e.g, [Heading IDs](https:/www.eff.org/page#heading-ids)).
Definition Lists
Some Markdown processors allow you to create definition lists of terms and their
corresponding definitions. To create a definition list, type the term on the first line.
On the next line, type a colon followed by a space and the definition.
Markdown
1 First Term
2 : This is the definition of the first term.
3
4 Second Term
5 : This is one definition of the second term.
6 : This is another definition of the second term.
Extended Syntax 47
HTML
1 <dl>
2 <dt>First Term</dt>
3 <dd>This is the definition of the first term.</dd>
4 <dt>Second Term</dt>
5 <dd>This is one definition of the second term. </dd>
6 <dd>This is another definition of the second term.</dd>
7 </dl>
First Term
This is the definition of the first term.
Second Term
This is one definition of the second term.
This is another definition of the second term.
Strikethrough
You can “strikethrough” words by putting a horizontal line through the center of
them. This feature allows you to indicate that certain words are a mistake not meant
for inclusion in the document. To strikethrough words, use two tilde symbols (∼∼)
before and after the words.
Markdown
HTML
Task Lists
Task lists allow you to create a list of items with checkboxes. In Markdown
applications that support task lists, checkboxes will be displayed next to the content.
To create a task list, add dashes (-) and brackets with a space ([ ]) in front of task
list items. To select a checkbox, add an x in between the brackets ([x]).
Markdown
Task list
1 http://example.com
Extended Syntax 49
HTML
1 <a href="http://example.com">http://example.com</a>
1 `http://www.example.com`
HTML
1 <code>http://www.example.com</code>
Basic Syntax
These are the elements outlined in John Gruber’s original design document. All
Markdown applications support these elements.
Code `code`
Link [title](https://www.example.com)
Extended Syntax
These elements extend the basic syntax by adding additional features. Not all
Markdown applications support these elements.