# The Markdown Tutorial # **By Ryan Hodson ( aka [Slekx](http://slekx.com) )** Markdown is a lightweight markup language designed to convert plain text into HTML. It lets you write in a human-readable format, then does the HTML conversion for you. Markdown was originally written by John Gruber in PERL, but has since been ported to many other languages. This tutorial will guide you through everything you need to know about the Markdown syntax. A detailed description of Markdown can be found at the [Markdown Homepage](http://daringfireball.net/projects/markdown/). This tutorial is a plain text document that needs to be formatted with Markdown. As you work through each section, you will learn a little background about each Markdown element, and then you will be prompted to add your own Markdown formatting. Don't be alarmed if you see some markup that you don't understand yet. Everything will be explained by the end of the tutorial. The instructions will guide you along the way. By the end of the tutorial, you will have transformed this document into a nicely formatted Markdown reference for later use. If you don't want to format it yourself, a copy of the completed tutorial can be found [here](http://slekx.com/the-markdown-tutorial-complete.txt). Let's get started. ********************************************************************** # Markdown and HTML # Notice that instructions look just like HTML comments. That's because HTML formatting can be inserted directly into a Markdown document. Try adding `` tags to the following line: This wimpy string of text is soon to become a BOLD string of text. Markdown is (usually) smart enough to know when you are trying to add HTML to a document, versus when you just want to add a < or a > or a & character. For example, The less than sign in 3 < 4 is NOT recognized as HTML The ampersand in AT&T is NOT recognized as HTML Items wrapped in HTML tags are recognized as HTML HTML escape sequences like & and © are recognized as HTML. Generally, you shouldn't have to worry about whether or not a character is escaped properly, Markdown should do it for you. One common exception is when you write about HTML and you want to show a <tag>, you will have to escape it by hand. Later, we will cover a more convenient way to write about code. For now, just remember that whenever you come across some kind of formatting that you can't make in Markdown, you can just switch to HTML. ********************************************************************** Header Elements A header element is tranformed into '`

,

,...,

`' tags in HTML. There are two ways to make a header in HTML: Atx Style Headers The first method is by using a `#` (pound sign) before the text of the header. The number of `#` characters that you use denotes the level of the header tag. So, `#` translates to `

`, `##` translates to `

` and so on, up to `

`. You may enclose the header by the same number of `#` signs. This is not required, but it does make your plain text easier to read. The following is an `

` header. ### This is important information ### Setext Style Headers The second method is by 'underlining' the text of the header with `-` (minus sign) or `=` (equal sign) characters. The `=` translates to `

`, while `-` translates to `

`. Higher lever header tags are not supported. The following is an example of an `

` header. This info is more important that the last info. =============================================== Note that you don't have to underline the entire title, one `-` or `=` will suffice. However, underlining all of it makes your plain text more readable. ********************************************************************** Paragraphs and Line Breaks Paragraphs, denoted by '<p>' tags in HTML, are a very natural entity in Markdown syntax. To create a paragraph, simply leave a blank line after the text that you want to mark as a paragraph. For example, THIS IS PART OF MY FIRST PARAGRAPH. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sed arcu est. Aliquam augue lorem, fringilla non sagittis a, eleifend at purus. Sed lectus mauris, semper interdum suscipit quis, aliquet vel diam. Cras a metus vitae ligula dignissim placerat. THIS IS PART OF MY SECOND PARAGRAPH. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sed arcu est. Aliquam augue lorem, fringilla non sagittis a, eleifend at purus. Sed lectus mauris, semper interdum suscipit quis, aliquet vel diam. Cras a metus vitae ligula dignissim placerat. Line breaks are handled a little differently that you might expect. HTML `
` tags are NOT inserted at every newline in your plain text. This means that simply typing a 'return' will not produce a `
` tag in the resulting HTML. To insert an HTML break tag, you need to end a line with TWO spaces, then press return. For example, This line ends with two spaces. This should be on the second line. This line does not end with two spaces. This should still be on the same line. The implication for this behavior is the ability to format your plain text with newlines, without forcing the newlines into your HTML document (e.g., your text will be a solid block in your HTML, filling the entire width of the enclosing `
` tags, while retaining line breaks in the plain text version). This paragraph is a case-in-point. ********************************************************************** Emphasis Markdown uses `*` (asterisk) and `_` (underscore) characters as indicators of emphasis. Enclose the emphasized text with one character for italic text (HTML `` tags), two characters for bold text (HTML `` tags), and three characters for text that is both italicized and bold. You can use either one, *but* you must make sure that the opening and closing character are the same (no mixing and matching `*` and `_` in the same span of text). ***This text has three levels of emphasis.*** If you want to include a literal `*` or `_`, you must escape it with a backslash. The quick brown fox jumps over the lazy dog. ********************************************************************** Horizontal Rules Horizontal rules are denoted by `
` in HTML. To create a horizontal rule in markdown, place three or more consecutive `*` (asterisk), `-` (minus sign), or `_` (underscore) characters on an empty line. Optionally, they may have spaces between them. For example, `* * *` will produce the same horizontal rule as `------------------`. Generally, I tend to fill a whole line with `*` because it makes it easier to see the horizontal rule in plain text. Lists Markdown supports both unordered and ordered lists, denoted in HTML by `