Skip to main content

How to Indent in Markdown

Indenting paragraphs, nested lists, list content, and code, plus the spacing rules that decide whether an indent nests, disappears, or turns into a code block.

Short answer

Markdown has no indent for ordinary text: up to 3 leading spaces are dropped, and 4 or more (or a tab) at the start of a block make a code block. To indent a paragraph's first line, start it with   or a few  . To nest a list item, line it up under the parent's text: 2 spaces under -, 3 under 1.. To set a whole block in, use >.

Indent a Paragraph

Spaces at the start of a paragraph do not indent it. CommonMark strips up to 3 of them, and 4 or more start a code block. For a visual indent, type an HTML entity at the start of the line. The parser turns it into a real non-breaking or em-width space, which is not stripped and not collapsed.

First-line indent with HTML entities
    This first line is indented with four non-breaking spaces.

 This one starts with a single em space.
Preview

    This first line is indented with four non-breaking spaces.

 This one starts with a single em space.

  is one regular-width space; repeat it.   is as wide as the letter M, so one is a typical paragraph indent.   is half that.

What plain spaces do
   Three leading spaces are dropped.

    Four leading spaces make a code block.
Preview

Three leading spaces are dropped.

Four leading spaces make a code block.

The first paragraph renders flush left. The second becomes a code block.

Indent a whole block with >
A normal paragraph.

> A whole block set in from the margin.
> Markdown treats it as a quotation.
Preview

A normal paragraph.

A whole block set in from the margin. Markdown treats it as a quotation.

Every line is set in, with a quote bar in most themes. Use it when the text really is a quote or callout.

CSS only works where HTML styles survive. <p style="text-indent: 2em"> indents on a static site you control, but GitHub strips style attributes, so the entity method is the one that works in a README.

Indent a Bullet List

A nested item belongs to the item above it when its marker sits at or past the start of the parent's text. Under - that is 2 spaces. Up to 3 more still nest, so 4 spaces works too, which is what Python-Markdown (MkDocs) requires.

Nested bullets, 2 spaces
- Fruits
  - Apple
  - Banana
- Vegetables
  - Carrot
Preview
  • Fruits
    • Apple
    • Banana
  • Vegetables
    • Carrot

Indent a Numbered List

A number marker is wider, so the child moves over with it: 3 spaces under 1. , 4 under 10. . The full nesting rules are in the nested lists guide.

Nested under numbers, 3 spaces
1. Phase one
   1. Task A
   2. Task B
2. Phase two
   - Task C
Preview
  1. Phase one
    1. Task A
    2. Task B
  2. Phase two
    • Task C

Indent Content Inside a List Item

A second paragraph, a code block, or an image belongs to a list item when it is indented to the item's text. Leave a blank line before it.

Second paragraph under a bullet
- First paragraph of this item.

  Second paragraph, indented 2 spaces
  so it stays inside the same item.

- Second item
Preview
  • First paragraph of this item.

    Second paragraph, indented 2 spaces so it stays inside the same item.

  • Second item

Second paragraph under a number
1. Item one.

   Continuation paragraph under item one.
   Three spaces, the width of "1. ", keep it inside.

2. Item two.
Preview
  1. Item one.

    Continuation paragraph under item one. Three spaces, the width of "1. ", keep it inside.

  2. Item two.

Indented code block inside a list item
- Run this command:

      npm install

- Then start the server.
Preview
  • Run this command:

    npm install
    
  • Then start the server.

The item's text starts at column 2, so the code needs 2 + 4 = 6 spaces. A ``` fence only needs the 2.

When Indentation Becomes a Code Block

Four or more spaces at the start of a new block make an indented code block. It cannot interrupt a paragraph, so a 4-space line directly under paragraph text just continues the paragraph; after a blank line, it is code. Fenced blocks with three backticks are clearer and allow a language hint.

Indented code block
A normal paragraph.

    function hello() {
      return "indented code block"
    }

Another normal paragraph.
Preview

A normal paragraph.

function hello() {
  return "indented code block"
}

Another normal paragraph.

Tabs vs Spaces

CommonMark does not swap tabs for a fixed number of spaces. Where indentation matters, a tab moves to the next tab stop, and tab stops are every 4 columns. In practice:

  • A tab at the start of a line counts as 4 spaces, so a line that starts with a tab after a blank line is a code block.
  • A tab before a nested - reaches column 4, which nests under both - and 1. parents.
  • Editors disagree about what the Tab key inserts. Obsidian's Tab indents the selected list items; other editors insert a tab or a configured number of spaces. Spaces render the same everywhere.

Indent with Blockquotes

Each > sets text in one more level. The space between the > characters is optional. More on line breaks, attribution, and callouts in the blockquote guide.

Nested blockquotes
> Outer quote
> > Inner quote
> > > Deepest quote
Preview

Outer quote

Inner quote

Deepest quote

Common Mistakes

Indentation goes wrong in three ways: too little, too much, or in the wrong place for a paragraph.

Broken

- Parent
 - Child

Fixed

- Parent
  - Child
The parent's text starts 2 columns in, so a child needs at least 2 spaces. With 1 space it is a sibling, not a child.

Broken

1. Parent
  - Child

Fixed

1. Parent
   - Child
Under a number the text starts later. "1. " is 3 characters wide, so the child needs 3 spaces (4 under "10. ").

Broken

- Parent
      - Child

Fixed

- Parent
  - Child
Too much indentation breaks nesting too. More than 3 spaces past the parent's text is not a list item, so the line joins the parent's text as "Parent - Child".

Broken

Some text.

    I wanted an indent, not code.

Fixed

Some text.

&emsp;I wanted an indent, not code.
Four or more leading spaces at the start of a block make an indented code block. Use an HTML entity for a visual first-line indent.

Broken

- Item one.

Continuation of item one.

Fixed

- Item one.

  Continuation of item one.
After a blank line, an unindented paragraph ends the list. Indent it to the item's text to keep it inside the item.

Quick Reference

SyntaxResultNotes
&emsp;TextFirst-line indentOne em-wide space
&nbsp;&nbsp;TextFirst-line indentOne space per entity
- item - childNested bullet2 spaces under -
1. item - childNested under number3 spaces under 1.
- item More textSecond paragraph in itemIndent to the item's text
code lineIndented code block4+ spaces or a tab, new block
> quote > > nestedIndented quote blockOne > per level

Platform Support

Document renderers follow CommonMark. Python-Markdown and the chat apps are where the numbers change.

PlatformSupported?Notes
CommonMark / GFMYesLists nest by the parent's content column, 4 spaces start a code block, and tabs count to the next multiple of 4.
GitHubYesCommonMark rules. &nbsp; and &emsp; work; style attributes such as text-indent are stripped.
GitLabYesCommonMark rules; its docs say to indent continuation paragraphs to the start of the item's text.
VS Code previewYesCommonMark rules through markdown-it.
ObsidianYesTab and Shift+Tab indent list items. A Tab or 4 spaces makes a code block.
MkDocs (Python-Markdown)PartialNested list content needs 4 spaces (or a tab) per level, not 2.
RedditYesSublists need 2 spaces under a bullet, 3 under a number. 4-space code blocks work on old and new Reddit.
NotionPartialTab nests a block under the one above it, and Shift+Tab un-nests it.
DiscordPartial2 spaces before - or * indents a list item. Code blocks use ``` fences, not indentation.
SlackPartialmrkdwn has no list or indent syntax. The composer builds lists as you type; apps can send nested lists in a markdown block.

Frequently Asked Questions

How do I indent in Markdown?

It depends on what you are indenting. For a nested list item, indent it to the parent's text: 2 spaces under -, 3 under 1. For the first line of a paragraph, start it with &nbsp;&nbsp;&nbsp;&nbsp; or &emsp;. For a whole block, use a > blockquote. Plain leading spaces do not indent normal text.

How do I indent a paragraph in Markdown?

Markdown has no paragraph-indent syntax. Up to 3 leading spaces are ignored, and 4 or more make a code block. For a visual first-line indent, type HTML entities at the start of the line: &nbsp; (one space each, repeat it) or &emsp; (one em-wide space). Where HTML styles are allowed you can use CSS text-indent, but GitHub strips style attributes.

Why does my indented text turn into a code block?

Four or more spaces, or a tab, at the start of a new block create an indented code block. That only happens when the line is not continuing a paragraph, which is why it usually bites after a blank line. Inside a list, the 4 spaces are counted from the item's text, not from the left margin.

How do I indent without creating a code block?

Use fewer than 4 spaces for list nesting (2 under -, 3 under 1.), use &nbsp; or &emsp; entities for a visual indent, or use > for an indented block. Leading spaces alone never indent a normal paragraph.

How do I indent a bullet point or nested list?

Put the child's marker under the first character of the parent's text. That is 2 spaces under a - item and 3 under a 1. item. Python-Markdown (MkDocs) is stricter and wants 4 spaces per level, and 4 also works in CommonMark, so 4 is the portable choice.

Is a tab 4 spaces in Markdown?

For structure, effectively yes. CommonMark keeps tabs as tabs, but when they affect indentation it treats them as moving to the next tab stop, at multiples of 4 columns. So a tab at the start of a line counts as 4 spaces and makes a code block, while a tab after a list marker only reaches the next stop. Spaces are more predictable across editors.

How do I put a code block inside a list item?

Indent a fenced block to the item's text: 2 spaces under -, 3 under 1. An indented (4-space) code block needs the item's indent plus 4, so 6 spaces under a - item. Leave a blank line before it.

How do I add a second paragraph to a list item?

Leave a blank line after the first paragraph, then indent the next one to the same column as the item's text. Without the indent, the paragraph ends the list.

How do I nest a blockquote?

Add another > for each level: > outer, > > inner. The space between them is optional; >> works too.

Do Slack and Discord support indentation?

Discord indents a list item when you put 2 spaces before the - or *. Slack's mrkdwn has no list or indent syntax; its composer creates lists as you type, and apps can send nested lists in a Block Kit markdown block.