Menu
Coddy logo textTech

Markdown Cheat Sheet

Last updated

Headings

Put a space after the # signs. The number of signs sets the level, from 1 to 6.

ElementMarkdownResult
Heading 1# Page titleTop-level heading, <h1>
Heading 2## SectionSection heading, <h2>
Heading 3### SubsectionSubsection heading, <h3>
Headings 4 to 6#### Level 4 ##### Level 5 ###### Level 6<h4>, <h5> and <h6>
Heading 1, alternatePage title ==========<h1>, the same as # Page title
Heading 2, alternateSection -------<h2>, the same as ## Section
Closing hashes## Section ##<h2>Section</h2>; trailing # signs are dropped
Missing space#Not a headingA plain paragraph. The space after # is required

Bold, italic and strikethrough

Asterisks work anywhere, even inside a word. Underscores only work at word boundaries, so snake_case stays as typed.

ElementMarkdownResult
Bold**bold text**Bold, <strong>bold text</strong>
Bold, underscores__bold text__Bold, the same as above
Italic*italic text*Italic, <em>italic text</em>
Italic, underscores_italic text_Italic, the same as above
Bold and italic***bold and italic***<em><strong>bold and italic</strong></em>
Bold inside a wordun**believ**ableOnly the middle of the word is bold
Underscores in a wordsnake_case_namePlain text, no italic
Strikethrough (GFM)~~no longer true~~Crossed out, <del>no longer true</del>
Underline<ins>underlined</ins>Underlined text. Markdown has no underline syntax, so this is HTML
Highlight<mark>highlighted</mark>Highlighted text where the site allows the <mark> tag. Markdown has no highlight syntax

Line breaks and paragraphs

Pressing Enter once inside a paragraph does not start a new line in the output. Use one of these instead.

ElementMarkdownResult
New paragraphFirst paragraph. Second paragraph.Two paragraphs. A blank line separates them
Break: two spacesRoses are red, Violets are blue.One paragraph with a <br> after red,. The first line ends with two spaces, which you cannot see
Break: backslashRoses are red,\ Violets are blue.The same <br>, with a marker you can see. Works in CommonMark and on GitHub
Break: HTMLRoses are red,<br>Violets are blue.The same <br>. Also works inside a table cell
Single newlineRoses are red, Violets are blue.One line: Roses are red, Violets are blue. GitHub issues and comments keep the break; .md files do not
Extra blank linesOne. Two.The same as one blank line. For more space, put <br> on its own line

Lists

Indent a nested item so it lines up with the text of the item above: 2 spaces under - , 3 spaces under 1. .

ElementMarkdownResult
Bulleted list- Apples - Pears - PlumsA bulleted list, <ul> with three <li>
Other bullets* Apples + Pears* and + also make bullets. Switching the character starts a new list
Numbered list1. Install 2. Configure 3. RunA numbered list, <ol>
Lazy numbering1. Install 1. Configure 1. RunStill numbered 1, 2, 3. Only the first number counts
Start at a number7. Seventh 8. Eighth<ol start="7">, numbered from 7
Nested list- Fruit - Apple - Pear - VegetablesA list inside the first item
Nested, numbered1. Download - Windows - macOS 2. InstallBullets inside step 1, indented 3 spaces
Paragraph in an item- First item More about the first item. - Second itemTwo paragraphs inside the first item
Code in an item1. Run this: ```bash npm install ``` 2. Start the appA code block inside step 1, indented to the item's text

Task lists (checkboxes)

A GitHub Flavored Markdown extension: a list item that starts with [ ] or [x] becomes a checkbox.

ElementMarkdownResult
Empty checkbox- [ ] Write testsAn unticked checkbox
Ticked checkbox- [x] Write testsA ticked checkbox. [X] works too
Checklist- [x] Draft - [ ] Review - [ ] PublishOne ticked box and two empty ones. In GitHub issues and pull requests you can tick them with a click
Nested tasks- [ ] Release - [x] Tag the commit - [ ] Write the notesTwo sub-tasks under the first box
Missing space- [] Write testsA plain bullet that reads [] Write tests. The brackets need a space or an x

The link text goes in square brackets and the address in parentheses right after it, with no space between them.

ElementMarkdownResult
Inline link[Coddy](https://coddy.tech)<a href="https://coddy.tech">Coddy</a>
Link with a title[Coddy](https://coddy.tech "Learn to code")The same link. The title shows as a tooltip on hover
URL in angle brackets<https://coddy.tech>The URL itself, as a link
Bare URL (GFM)https://coddy.techA link on GitHub and other GFM sites, which also link www. addresses. Plain text in strict CommonMark
Email link<hello@example.com>A mailto: link
Reference linkRead the [docs][1]. [1]: https://example.com/docsdocs links to the URL. The [1]: line is not shown
Shortcut referenceSee [GitHub]. [GitHub]: https://github.comGitHub links to the URL
Relative link[Install guide](docs/install.md)A link to a file relative to this one. On GitHub it opens the file in the repository
Link to a heading[Jump to setup](#getting-started)Scrolls to ## Getting Started on the same page
Heading IDs## Getting Started!Gets the ID getting-started on GitHub: lower case, spaces become hyphens, punctuation other than - and _ is dropped
Heading in another file[Requirements](docs/install.md#requirements)Opens the file at that heading
Spaces in the URL[Report](my%20report.pdf)Write each space as %20, or wrap the URL in angle brackets: [Report](<my report.pdf>)
Open in a new tab<a href="https://coddy.tech" target="_blank">Coddy</a>Markdown has no syntax for this. The HTML works where the site keeps the target attribute

Images

An image is a link with ! in front. The text in the brackets becomes the alt text, which screen readers read aloud.

ElementMarkdownResult
Image![A cat asleep on a sofa](cat.png)<img src="cat.png" alt="A cat asleep on a sofa">
Image with a title![Logo](logo.png "Coddy logo")The same image with a tooltip on hover
Image from a URL![Build status](https://example.com/badge.svg)Loads the image from the web
Linked image[![Logo](logo.png)](https://coddy.tech)An image that opens the link when clicked
Reference image![Logo][logo] [logo]: images/logo.pngThe same as an inline image, with the URL defined once below
Image size<img src="logo.png" alt="Logo" width="200">The image, 200 pixels wide. Plain Markdown has no size syntax, so this is an HTML <img> tag
Centered image<p align="center"> <img src="logo.png" alt="Logo" width="200"> </p>A centered image, as seen in many GitHub README files

Code and code blocks

Backticks mark code inside a line; a fence of three backticks marks a block. Nothing inside code is formatted.

ElementMarkdownResult
Inline codeRun `npm install` first.npm install in a monospace font, as <code>
Backtick inside code``Use `git` here``The code Use `git` here. Wrap it in more backticks than it contains
Code block``` npm install npm run dev ```A block, <pre><code>, with the line breaks kept
Syntax highlighting```python def greet(name): return f"Hello, {name}" ```A Python block with colored syntax. Common names: js, ts, python, bash, json, html, css, sql
Tilde fence~~~js console.log("hi"); ~~~The same as a backtick fence
Indented code const total = 42;A code block made by 4 spaces of indent, after a blank line
Diff block```diff - const x = 1; + const x = 2; ```Removed lines in red and added lines in green on GitHub
Fence inside a block````markdown ```js let a = 1; ``` ````A block that shows the inner fence as text. The outer fence needs more backticks than the inner one

Tables

A GitHub Flavored Markdown extension. The second line, the delimiter row, turns the first line into a header. It must have the same number of cells as the header, or no table is made.

ElementMarkdownResult
Table| Name | Role | | ----- | ------ | | Ada | Admin | | Linus | Editor |A table with a header row and two rows
Column alignment| Left | Center | Right | | :--- | :----: | ----: | | a | b | c |Colons set the alignment: left, centered, right
No outer pipesName | Role --- | --- Ada | AdminThe same table. The pipes at the start and end of a line are optional
Column width| a | b | |---|---| | 1 | 2 |Widths come from the content. The number of hyphens does not matter, and the pipes need not line up
Formatting in cells| Command | Does | | --- | --- | | `git status` | Shows **changed** files |Code, bold, links and images all work inside cells
Pipe inside a cell| Operator | Meaning | | --- | --- | | `a \| b` | a or b |The cell shows a | b. Escape the pipe as \|, even inside code
Line break in a cell| Step | Notes | | --- | --- | | 1 | First line<br>Second line |Two lines in one cell. A real newline would end the row
Merged cells<td colspan="2">Both columns</td>Markdown tables cannot merge cells. Write the table in HTML with colspan or rowspan

Blockquotes

Start each line with >. A blockquote can hold any other Markdown.

ElementMarkdownResult
Blockquote> Simple is better than complex.An indented quote, <blockquote>
Several paragraphs> First paragraph. > > Second paragraph.One quote with two paragraphs. The bare > line keeps them together
Nested quote> The reply >> The original messageA quote inside a quote
Other elements inside> #### Note > - Back up first > - Then upgradeA heading and a list inside the quote
Alert (GitHub)> [!NOTE] > Requires Node 20 or later.A colored Note box on GitHub. The other types are [!TIP], [!IMPORTANT], [!WARNING] and [!CAUTION]

Horizontal rules

Three or more hyphens, asterisks or underscores alone on a line draw a line across the page.

ElementMarkdownResult
Rule---A horizontal line, <hr>
Other forms*** ___Two more rules
Rule after textSome text ---A paragraph, then a rule. Keep the blank line
Missing blank lineSome text ---A level 2 heading, not a rule: --- under a line of text underlines it

Footnotes

Supported on GitHub, GitLab and many static site generators. Strict CommonMark has no footnotes.

ElementMarkdownResult
FootnoteMarkdown dates from 2004.[^1] [^1]: John Gruber created it, with Aaron Swartz.A superscript 1 that links to the note, listed at the bottom of the page
Named footnoteSee the spec.[^spec] [^spec]: https://spec.commonmark.orgLabels can be words, but the notes are still numbered 1, 2, 3 in order of use
Where to define it[^1]: The text of the note.The definition can sit anywhere in the file. It always renders at the end

Escaping characters

A backslash before a punctuation character prints the character itself instead of formatting.

ElementMarkdownResult
Literal asterisks\*not italic\*Plain text with the asterisks: *not italic*
Literal hash\# Not a headingA paragraph that starts with #
Number and a period2024\. A good year.A paragraph, not a list that starts at 2024
Literal brackets\[not a link\](page.md)The brackets and parentheses as typed
Literal backtick\`One backtick
Literal backslash\\One backslash
What can be escaped\ ` * _ {} [] () <> # + - . ! |Any ASCII punctuation. A backslash before a letter or digit stays a backslash
HTML entities&copy; 2026 &amp; &lt;div&gt;© 2026 & <div>, as text
No escaping in code`*stars*`The code *stars* as typed. Inside code a backslash is a plain character

HTML inside Markdown

Most renderers pass HTML through, so a tag covers what Markdown has no syntax for. GitHub removes unsafe HTML such as <script>, <style>, <iframe> and style attributes.

ElementMarkdownResult
Keyboard keysPress <kbd>Ctrl</kbd> + <kbd>C</kbd>Ctrl and C drawn as keys
Sub and superscriptH<sub>2</sub>O and x<sup>2</sup>H₂O and x²
Collapsible section<details> <summary>Show the answer</summary> The answer is **42**. </details>A section that opens on click. The blank lines let the Markdown inside it render
Markdown in an HTML block<div> **not bold** </div>**not bold** as typed. Markdown is not read inside an HTML block until a blank line ends the block
Colored text<span style="color: red">red</span>Red text on sites that allow inline styles. GitHub removes the style attribute

Comments

Markdown has no comment syntax. Two tricks keep text off the rendered page.

ElementMarkdownResult
Hidden comment[//]: # (This line is never shown)Nothing. The line is a link definition that no link uses, so it never reaches the HTML
Alternate form[comment]: <> (Also hidden)Nothing, by the same trick
HTML comment<!-- TODO: add screenshots -->Nothing on the page, but the comment stays in the HTML source
Multi-line comment<!-- This whole block is hidden -->Nothing on the page
PlacementSome text. [//]: # (comment) More text.Two paragraphs. The comment line needs a blank line before it, or it shows as text

GitHub Flavored Markdown and GitHub extras

GitHub Flavored Markdown (GFM) is CommonMark plus tables, task lists, strikethrough and bare URL links. GitHub adds more on top.

FeatureMarkdownWhere it works
Tables| a | b | | --- | --- | | 1 | 2 |GFM: GitHub, GitLab and most documentation tools
Task lists- [x] DoneGFM
Strikethrough~~text~~GFM
Bare URL linkswww.coddy.techGFM
Code with a language```js let a = 1; ```CommonMark and GFM. The colors come from the site
FootnotesText.[^1] [^1]: Note.GitHub and GitLab, though not in the GFM spec
Emoji:rocket: :tada:GitHub and GitLab turn shortcodes into emoji
Mentions@octocatGitHub: links the user and notifies them
Issue links#123GitHub: links issue or pull request 123 in the same repository
Diagrams```mermaid graph LR A --> B ```GitHub and GitLab draw a Mermaid diagram
Math$E = mc^2$ $$ \sum_{i=1}^{n} i $$GitHub renders LaTeX math, inline between $ signs and as a block between $$ lines

Every piece of Markdown syntax on one page, next to what it turns into. This Markdown cheat sheet covers the core syntax (headings, emphasis, line breaks, lists, links, images, code, blockquotes) and the GitHub Flavored Markdown extras: tables with alignment, task lists, strikethrough, bare URL links and footnotes, plus escaping, HTML and comments.

The examples follow CommonMark and GitHub Flavored Markdown, the rules GitHub, GitLab and most documentation tools build on. Where a site behaves differently, the row says so. To watch any example render as you type, paste it into the Markdown editor.

Markdown cheat sheet FAQ

How do I make a table in Markdown?
Write the header row with cells between pipes, then a delimiter row of hyphens, then one line per row: | Name | Role |, | --- | --- |, | Ada | Admin |. Colons in the delimiter row align a column: :--- left, :---: centered, ---: right. Tables are a GitHub Flavored Markdown feature, so they work on GitHub, GitLab and most documentation tools, but not in strict CommonMark.
How do I add a new line in Markdown?
A single line break inside a paragraph is ignored in the output. To force a line break, end the line with two spaces or a backslash (\), or write <br>. To start a new paragraph, leave a blank line. GitHub issues and comments are the exception: there a single newline already shows as a line break.
How do I write a comment in Markdown?
Markdown has no comment syntax, but two tricks work. [//]: # (your comment) on its own line, with a blank line before it, is a link definition that nothing uses, so it never reaches the page or the HTML. An HTML comment, <!-- your comment -->, is also hidden on the page but stays in the HTML source, where anyone who views the source can read it.
How do I make a code block in Markdown?
Put three backticks on the line before the code and three on the line after it. Add a language name after the opening backticks, as in ```python, to get syntax highlighting. For code inside a sentence, wrap it in single backticks: `npm install`.
How do I add a checkbox in Markdown?
Start a list item with [ ] for an empty box or [x] for a ticked one: - [ ] Review or - [x] Draft. Keep the space inside the empty brackets. Checkboxes are part of GitHub Flavored Markdown, and in GitHub issues and pull requests you can tick them with a click.
How do I change the size of an image in Markdown?
Plain Markdown has no size syntax: ![alt text](image.png) always shows the image at its own size. Use an HTML tag instead, such as <img src="image.png" alt="alt text" width="300">, which GitHub and most renderers accept. Set only the width or only the height to keep the proportions.
How do I link to a heading in Markdown?
Link to the heading's ID with #: [Setup](#getting-started) jumps to ## Getting Started. GitHub builds the ID from the heading text in lower case, with spaces turned into hyphens and punctuation other than hyphens and underscores removed. For a heading in another file, put the ID after the file name: [Setup](docs/install.md#getting-started).
What is a .md file?
A plain text file written in Markdown. .md and .markdown are the usual extensions, and README.md is the file GitHub shows on the front page of a repository. Any text editor opens one; GitHub, documentation sites and Markdown viewers render it as formatted text. To see a file rendered as you edit it, paste it into the Markdown editor.
Coddy programming languages illustration

Learn Markdown with Coddy

GET STARTED