1<h1>Markdown: Basics</h1>
2<ul id="ProjectSubmenu">
3    <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
4    <li><a class="selected" title="Markdown Basics">Basics</a></li>
5    <li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
6    <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
7    <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
8</ul>
9<h2>Getting the Gist of Markdown's Formatting Syntax</h2>
10<p>This page offers a brief overview of what it's like to use Markdown.
11The <a href="/projects/markdown/syntax" title="Markdown Syntax">syntax page</a> provides complete, detailed documentation for
12every feature, but Markdown should be very easy to pick up simply by
13looking at a few examples of it in action. The examples on this page
14are written in a before/after style, showing example syntax and the
15HTML output produced by Markdown.</p>
16<p>It's also helpful to simply try Markdown out; the <a href="/projects/markdown/dingus" title="Markdown Dingus">Dingus</a> is a
17web application that allows you type your own Markdown-formatted text
18and translate it to XHTML.</p>
19<p><strong>Note:</strong> This document is itself written using Markdown; you
20can <a href="/projects/markdown/basics.text">see the source for it by adding '.text' to the URL</a>.</p>
21<h2>Paragraphs, Headers, Blockquotes</h2>
22<p>A paragraph is simply one or more consecutive lines of text, separated
23by one or more blank lines. (A blank line is any line that looks like a
24blank line -- a line containing nothing spaces or tabs is considered
25blank.) Normal paragraphs should not be intended with spaces or tabs.</p>
26<p>Markdown offers two styles of headers: <em>Setext</em> and <em>atx</em>.
27Setext-style headers for <code>&lt;h1&gt;</code> and <code>&lt;h2&gt;</code> are created by
28"underlining" with equal signs (<code>=</code>) and hyphens (<code>-</code>), respectively.
29To create an atx-style header, you put 1-6 hash marks (<code>#</code>) at the
30beginning of the line -- the number of hashes equals the resulting
31HTML header level.</p>
32<p>Blockquotes are indicated using email-style '<code>&gt;</code>' angle brackets.</p>
33<p>Markdown:</p>
34<pre><code>A First Level Header
35====================
36
37A Second Level Header
38---------------------
39
40Now is the time for all good men to come to
41the aid of their country. This is just a
42regular paragraph.
43
44The quick brown fox jumped over the lazy
45dog's back.
46
47### Header 3
48
49&gt; This is a blockquote.
50&gt;
51&gt; This is the second paragraph in the blockquote.
52&gt;
53&gt; ## This is an H2 in a blockquote
54</code></pre>
55<p>Output:</p>
56<pre><code>&lt;h1&gt;A First Level Header&lt;/h1&gt;
57
58&lt;h2&gt;A Second Level Header&lt;/h2&gt;
59
60&lt;p&gt;Now is the time for all good men to come to
61the aid of their country. This is just a
62regular paragraph.&lt;/p&gt;
63
64&lt;p&gt;The quick brown fox jumped over the lazy
65dog's back.&lt;/p&gt;
66
67&lt;h3&gt;Header 3&lt;/h3&gt;
68
69&lt;blockquote&gt;
70    &lt;p&gt;This is a blockquote.&lt;/p&gt;
71
72    &lt;p&gt;This is the second paragraph in the blockquote.&lt;/p&gt;
73
74    &lt;h2&gt;This is an H2 in a blockquote&lt;/h2&gt;
75&lt;/blockquote&gt;
76</code></pre>
77<h3>Phrase Emphasis</h3>
78<p>Markdown uses asterisks and underscores to indicate spans of emphasis.</p>
79<p>Markdown:</p>
80<pre><code>Some of these words *are emphasized*.
81Some of these words _are emphasized also_.
82
83Use two asterisks for **strong emphasis**.
84Or, if you prefer, __use two underscores instead__.
85</code></pre>
86<p>Output:</p>
87<pre><code>&lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
88Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
89
90&lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
91Or, if you prefer, &lt;strong&gt;use two underscores instead&lt;/strong&gt;.&lt;/p&gt;
92</code></pre>
93<h2>Lists</h2>
94<p>Unordered (bulleted) lists use asterisks, pluses, and hyphens (<code>*</code>,
95<code>+</code>, and <code>-</code>) as list markers. These three markers are
96interchangable; this:</p>
97<pre><code>*   Candy.
98*   Gum.
99*   Booze.
100</code></pre>
101<p>this:</p>
102<pre><code>+   Candy.
103+   Gum.
104+   Booze.
105</code></pre>
106<p>and this:</p>
107<pre><code>-   Candy.
108-   Gum.
109-   Booze.
110</code></pre>
111<p>all produce the same output:</p>
112<pre><code>&lt;ul&gt;
113&lt;li&gt;Candy.&lt;/li&gt;
114&lt;li&gt;Gum.&lt;/li&gt;
115&lt;li&gt;Booze.&lt;/li&gt;
116&lt;/ul&gt;
117</code></pre>
118<p>Ordered (numbered) lists use regular numbers, followed by periods, as
119list markers:</p>
120<pre><code>1.  Red
1212.  Green
1223.  Blue
123</code></pre>
124<p>Output:</p>
125<pre><code>&lt;ol&gt;
126&lt;li&gt;Red&lt;/li&gt;
127&lt;li&gt;Green&lt;/li&gt;
128&lt;li&gt;Blue&lt;/li&gt;
129&lt;/ol&gt;
130</code></pre>
131<p>If you put blank lines between items, you'll get <code>&lt;p&gt;</code> tags for the
132list item text. You can create multi-paragraph list items by indenting
133the paragraphs by 4 spaces or 1 tab:</p>
134<pre><code>*   A list item.
135
136    With multiple paragraphs.
137
138*   Another item in the list.
139</code></pre>
140<p>Output:</p>
141<pre><code>&lt;ul&gt;
142&lt;li&gt;&lt;p&gt;A list item.&lt;/p&gt;
143&lt;p&gt;With multiple paragraphs.&lt;/p&gt;&lt;/li&gt;
144&lt;li&gt;&lt;p&gt;Another item in the list.&lt;/p&gt;&lt;/li&gt;
145&lt;/ul&gt;
146
147</code></pre>
148<h3>Links</h3>
149<p>Markdown supports two styles for creating links: <em>inline</em> and
150<em>reference</em>. With both styles, you use square brackets to delimit the
151text you want to turn into a link.</p>
152<p>Inline-style links use parentheses immediately after the link text.
153For example:</p>
154<pre><code>This is an [example link](http://example.com/).
155</code></pre>
156<p>Output:</p>
157<pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/"&gt;
158example link&lt;/a&gt;.&lt;/p&gt;
159</code></pre>
160<p>Optionally, you may include a title attribute in the parentheses:</p>
161<pre><code>This is an [example link](http://example.com/ "With a Title").
162</code></pre>
163<p>Output:</p>
164<pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/" title="With a Title"&gt;
165example link&lt;/a&gt;.&lt;/p&gt;
166</code></pre>
167<p>Reference-style links allow you to refer to your links by names, which
168you define elsewhere in your document:</p>
169<pre><code>I get 10 times more traffic from [Google][1] than from
170[Yahoo][2] or [MSN][3].
171
172[1]: http://google.com/        "Google"
173[2]: http://search.yahoo.com/  "Yahoo Search"
174[3]: http://search.msn.com/    "MSN Search"
175</code></pre>
176<p>Output:</p>
177<pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
178title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
179title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
180title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
181</code></pre>
182<p>The title attribute is optional. Link names may contain letters,
183numbers and spaces, but are <em>not</em> case sensitive:</p>
184<pre><code>I start my morning with a cup of coffee and
185[The New York Times][NY Times].
186
187[ny times]: http://www.nytimes.com/
188</code></pre>
189<p>Output:</p>
190<pre><code>&lt;p&gt;I start my morning with a cup of coffee and
191&lt;a href="http://www.nytimes.com/"&gt;The New York Times&lt;/a&gt;.&lt;/p&gt;
192</code></pre>
193<h3>Images</h3>
194<p>Image syntax is very much like link syntax.</p>
195<p>Inline (titles are optional):</p>
196<pre><code>![alt text](/path/to/img.jpg "Title")
197</code></pre>
198<p>Reference-style:</p>
199<pre><code>![alt text][id]
200
201[id]: /path/to/img.jpg "Title"
202</code></pre>
203<p>Both of the above examples produce the same output:</p>
204<pre><code>&lt;img src="/path/to/img.jpg" alt="alt text" title="Title" /&gt;
205</code></pre>
206<h3>Code</h3>
207<p>In a regular paragraph, you can create code span by wrapping text in
208backtick quotes. Any ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> or
209<code>&gt;</code>) will automatically be translated into HTML entities. This makes
210it easy to use Markdown to write about HTML example code:</p>
211<pre><code>I strongly recommend against using any `&lt;blink&gt;` tags.
212
213I wish SmartyPants used named entities like `&amp;mdash;`
214instead of decimal-encoded entites like `&amp;#8212;`.
215</code></pre>
216<p>Output:</p>
217<pre><code>&lt;p&gt;I strongly recommend against using any
218&lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
219
220&lt;p&gt;I wish SmartyPants used named entities like
221&lt;code&gt;&amp;amp;mdash;&lt;/code&gt; instead of decimal-encoded
222entites like &lt;code&gt;&amp;amp;#8212;&lt;/code&gt;.&lt;/p&gt;
223</code></pre>
224<p>To specify an entire block of pre-formatted code, indent every line of
225the block by 4 spaces or 1 tab. Just like with code spans, <code>&amp;</code>, <code>&lt;</code>,
226and <code>&gt;</code> characters will be escaped automatically.</p>
227<p>Markdown:</p>
228<pre><code>If you want your page to validate under XHTML 1.0 Strict,
229you've got to put paragraph tags in your blockquotes:
230
231    &lt;blockquote&gt;
232        &lt;p&gt;For example.&lt;/p&gt;
233    &lt;/blockquote&gt;
234</code></pre>
235<p>Output:</p>
236<pre><code>&lt;p&gt;If you want your page to validate under XHTML 1.0 Strict,
237you've got to put paragraph tags in your blockquotes:&lt;/p&gt;
238
239&lt;pre&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;
240    &amp;lt;p&amp;gt;For example.&amp;lt;/p&amp;gt;
241&amp;lt;/blockquote&amp;gt;
242&lt;/code&gt;&lt;/pre&gt;
243</code></pre>
244