Developer & Network Tools

Markdown Explained

Learn the Markdown syntax you will use most, why it looks different from app to app and how to avoid common surprises.

Key takeaways

  • Markdown files are ordinary text that stays readable even when nothing renders it.
  • Headings, emphasis, lists, links and code blocks cover most everyday writing.
  • Tables, task lists and footnotes are extensions that only some applications support.
  • CommonMark is a precise specification of the core syntax, and many tools build on it.
  • Software that turns other people's Markdown into HTML has to sanitize the result.

Markdown is a way of formatting plain text with a few punctuation marks. A # makes a heading, **two asterisks** make bold text, and a hyphen starts a list item. A program converts those marks into formatted output, usually HTML.

You'll meet it in code repositories, documentation, chat apps, note tools, forums, static websites and AI chatbot replies. Ten minutes with the basics lets you write comfortably in all of them, as long as you know that each one differs a little.

Where Markdown came from

John Gruber published Markdown in 2004, with Aaron Swartz contributing to its design. The aim was a format that reads naturally as plain text, borrowing conventions people already used in email, and converts cleanly into HTML.

The original description left many edge cases open, so implementations drifted apart. The CommonMark project later wrote a detailed specification with tests. GitHub Flavored Markdown builds on CommonMark and adds features such as tables and task lists.

Files normally end in .md. You can edit them in any text editor.

From plain text to a formatted page
1 Write Text with simple punctuation marks 2 Parse A processor reads the structure 3 Convert It produces HTML or another format 4 Sanitize Unsafe markup from others is removed 5 Style The site's CSS decides how it looks Write Text with simple punctuation marks 1 Parse A processor reads the structure 2 Convert It produces HTML or another format 3 Sanitize Unsafe markup from others is removed 4 Style The site's CSS decides how it looks 5

Headings, paragraphs and emphasis

Put one to six # characters and a space at the start of a line:

# Page title
## Section
### Subsection

Separate paragraphs with a blank line. A single line break inside a paragraph is usually treated as a space. To force a break, end the line with a backslash or two spaces, though some apps simply honor every newline.

Emphasis uses asterisks or underscores:

*italic*   **bold**   ***both***

Asterisks behave more predictably in the middle of words. A line beginning with > becomes a block quote, and three hyphens on their own line, with a blank line above, draw a horizontal rule. Without that blank line, the hyphens can turn the text above into a heading.

Use heading levels to show structure instead of picking one for its size. Readers using screen readers navigate by them.

Lists

- apples
- pears
    - a nested item

1. Unplug the router.
2. Wait.
3. Plug it back in.

Bullets can use -, * or +. Numbered lists start from your first number, and many writers use 1. for every line so reordering needs no renumbering.

Indentation causes most list trouble. Nested items and continuation paragraphs need to line up with the text of the parent item. Four spaces is a safe choice in many tools. Leave a blank line before a list so every processor recognizes it.

A short worked example

Here is a small set of instructions as you might write it for a shared team folder:

# Office printer

The printer is **by the kitchen door**.

## Add it on a laptop

1. Join the staff Wi-Fi.
2. Open your printer settings.
3. Choose *Add printer* and pick the office model.

> Guests should ask at the front desk.

If it does not appear, test the connection:

ping 192.168.1.50

Read as plain text, it's already clear: the title, the steps and the command are easy to spot. Rendered, it becomes a page with two headings, a numbered list, a quoted note and a code box. The address is a private network example; yours would differ.

Notice the habits in it. There is one top-level heading, each block is separated by a blank line, and the command sits in a fenced block so nobody copies stray punctuation with it. Those three habits prevent most rendering problems.

If you're drafting something longer, a Markdown notes tool or any editor with a live preview shows mistakes as you make them.

[Visit the example site](https://example.com/)
![A red bicycle against a wall](images/bicycle.jpg)
<https://example.com/>

The text in square brackets is what readers see. For images it becomes the alternative text, so describe what matters, using the advice on useful alt text.

Reference-style links keep long addresses out of your sentences:

See the [style guide][guide] before editing.

[guide]: https://example.com/docs/style

Relative links such as images/bicycle.jpg depend on where the file is rendered. Check them after publishing. Addresses containing spaces or parentheses may need percent encoding.

Code

Wrap a short fragment in backticks: ` git status `. For several lines, use a fenced block with three backticks before and after, and name the language to get syntax coloring where supported:

print("hello")

Inside code, Markdown characters are shown literally. If your sample itself contains three backticks, make the outer fence four. Indenting by four spaces also creates a code block, which explains why an accidentally indented paragraph suddenly appears in a monospace box.

To show a special character literally in normal text, put a backslash before it: \*not italic\*.

Extensions you may or may not have

Tables are the best-known extension:

| Port | Protocol |
|------|----------|
| 80   | HTTP     |
| 443  | HTTPS    |

A colon in the divider row sets alignment: :--- left, ---: right, :---: centered. Tables work well for small grids and badly for long prose.

Other common additions include - [ ] task lists, ~~strikethrough~~, footnotes, definition lists, front matter (a block of settings at the top of a file used by many static site generators), math notation and diagrams written as text. Each depends on the tool.

Core syntax and common extensions
Core, widely supported Headings and paragraphs Bold and italic Ordered and unordered lists Links and images Code spans and blocks Block quotes Extensions, check first Tables Task lists Strikethrough Footnotes Front matter Math and diagrams VS Core, widely supported Headings and paragraphs Bold and italic Ordered and unordered lists Links and images Code spans and blocks Block quotes Extensions, check first Tables Task lists Strikethrough Footnotes Front matter Math and diagrams

Why it looks different in each app

The app chooses the processor, the extensions and the styling. Chat programs often use a reduced dialect where, for instance, a single asterisk means bold, and headings may be ignored. Note apps may add their own link syntax. A forum may disable images.

To keep documents portable, stick to the core, leave blank lines around headings, lists and code blocks, and preview in the destination. If you need identical results across tools you control, pick one processor and specify CommonMark plus the named extensions.

Fix common rendering problems

What you see Likely cause Fix
Literal # at the start of a line No space after it Write # Title
List runs into the paragraph above Missing blank line Add one before the list
Table shows as pipes and dashes Tables unsupported, or divider row missing Add the divider row or check the app
Rest of the page is in a code box A fence was never closed Add the closing backticks
Nested list appears flat Too little indentation Indent to the parent's text
Words turn italic unexpectedly Stray asterisks or underscores Escape them or use code spans
Numbering restarts at one A block broke the list Indent the block under its item

A linter, a tool that checks a file against style rules, can catch many of these automatically in projects with lots of documents. It also keeps contributors consistent about bullet characters and heading levels.

When something renders strangely, shrink it. Copy the section into a preview, delete lines until it behaves, and the last thing you removed usually points to the cause.

Check chatbot output with the same eye. If you paste a reply into a program that doesn't render Markdown, you'll see the asterisks and pound signs. Look for a "copy as formatted text" option, or convert it first.

HTML, conversion and safety

Many processors pass raw HTML through, so you can add what Markdown lacks, such as <br> or a <details> block. Support is inconsistent and many sites strip it.

That pass-through is a security concern for developers. Rendering visitors' Markdown without cleaning the output can allow scripts into your pages. Disable raw HTML or run the output through a maintained sanitizer, and restrict link schemes, as described in injection and XSS.

Converting is easy in both directions. Try the Markdown to HTML and HTML to Markdown converters. The command line tool Pandoc converts to word processor files, PDF (with additional software) and more. Complex layouts rarely survive a round trip intact.

When Markdown is the wrong tool

Choose something else when you need precise page layout, tracked changes for reviewers who expect a word processor, merged table cells, heavy cross-referencing or many people editing visually at once. Other lightweight formats such as AsciiDoc and reStructuredText offer more structure for large technical manuals.

Markdown shines where you want text that lasts, compares cleanly in version control and can be read in any editor years from now. READMEs, meeting notes, how-to guides and blog posts all fit.

Common questions

Why did my line breaks disappear?

Single newlines are merged into one paragraph under standard rules. Add a blank line, or use an explicit hard break.

Why does a line starting with a year turn into a list?

A number followed by a period and a space can start an ordered list. Write it as 1998\. to keep it as text.

Can I add colors?

Plain Markdown has no color syntax. Some apps offer their own, or allow HTML, but it won't travel well.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in Developer & Network Tools →

Latest news on this topic