← Back to blog/Guides

Markdown Indentation: Lists, Code, and Paragraph Spacing

Understand what leading spaces actually mean in Markdown and choose structural indentation instead of fragile visual-spacing hacks.

F
Faizan Khan
• 5 min read

Markdown indentation usually expresses structure, not decorative paragraph spacing. Indent nested list content to the parent item's text column; at the top level, four leading spaces can create an indented code block. Standard Markdown has no universal command for a normal paragraph's first-line indent.

If your goal is simply to move prose a little to the right, first decide whether it is a quote, a nested step, a code sample, or a presentation preference. Those need different solutions.

Indent to the parent item's content

Markdown
1- Prepare the files.
2 - Check the filenames.
3 - Remove unused screenshots.
4
51. Prepare the files.
6 - Check the filenames.
7 - Remove unused screenshots.

The first child list uses two spaces because - is two characters wide. The second uses three because 1. is three characters wide. With 10. and one following space, use four.

This content-column model is more dependable than memorizing "nested lists always need two spaces." It also explains why a list can break when its starting number grows from one digit to two. See Markdown lists for a complete procedure with nested review criteria.

Use spaces consistently in examples. Tabs can appear aligned in your editor while being interpreted according to different tab stops by a parser. The CommonMark tab rules describe their structural effect.

Continue a paragraph inside a step

Markdown
11. Choose the destination.
2
3 Select a folder that the reviewer can access.
42. Export the files.

The second paragraph belongs to step one because it remains at that item's content indentation. Remove the indentation and it becomes a top-level paragraph that can split the list.

You can nest a blockquote or fenced code in the same way:

Markdown
11. Review the configuration.
2
3 > Keep the original file until the review is complete.
4
5 ```json
6 { "mode": "review" }
7 ```
82. Continue after approval.

The three-space offset belongs to the numbered-list container. It is not part of the quote text or JSON value. When a code block unexpectedly ends a step, check all of its lines, including the closing fence.

Four top-level spaces mean code, not a normal indent

With a blank line before it, this input creates code:

Markdown
1Example output:
2
3 Review completed.
4 No missing files.
HTML
1<p>Example output:</p>
2<pre><code>Review completed.
3No missing files.
4</code></pre>

The renderer may display that in a monospace font with a shaded background. It is not a normal paragraph that happens to have a margin.

Indented code cannot interrupt an ordinary paragraph in the same way a fence can, which is another reason to leave explicit blank lines around examples. For language labels and visible boundaries, use fenced code blocks instead.

Use blockquotes for quotations, not arbitrary margins

Markdown
1> The review must finish before publication.

A theme often indents this visually, but the generated structure is a blockquote. That communicates quoted material, not merely "move this text right."

Do not wrap the whole document in blockquotes to obtain a narrower column. It misrepresents the content and makes later conversion harder. If the passage is genuinely quoted, follow the blockquote guide and provide attribution where useful.

For a warning written by the page author, a labeled paragraph or supported callout is usually more accurate than treating the author's own instruction as an external quotation.

Presentation-only indentation belongs to styles

If you own the site's stylesheet and HTML is allowed, an explicit class can express a visual preference:

HTML
1<p class="intro-paragraph">This paragraph has a first-line indent.</p>
CSS
1.intro-paragraph {
2 text-indent: 1.5em;
3}

That is HTML and CSS, not portable Markdown. A hosted renderer may strip the class or prohibit custom styles. In MDX, JSX uses className instead of class; check the publication format before copying the example.

The MDN text-indent reference documents the layout property. If you instead want the entire block offset, that is a margin or padding decision, not first-line indentation.

Avoid repeated &nbsp; entities as a layout system. They insert actual nonbreaking spaces, can create awkward copying behavior, and do not establish a nested relationship. They are especially brittle when readers enlarge text or the page becomes narrow.

Diagnose indentation with a small fixture

When a large document renders incorrectly, reduce the problem to one parent item, one child item, and one continuation paragraph. Turn on visible whitespace, replace tabs with the intended spaces, and add the other blocks back one at a time.

Ask what the HTML should contain: a nested ul, another p inside an li, or a pre element? That question usually identifies the fix faster than adding spaces until the preview looks plausible. For a broader syntax reference, use the Markdown cheat sheet.

FAQ

How do I indent a normal Markdown paragraph?

Core Markdown does not provide a standard visual paragraph-indent command. Use the site's approved styles when the goal is presentation rather than document structure.

Why did adding spaces turn my text into code?

At the top level, four leading spaces can start an indented code block. Remove that indentation for prose or use a documented CSS class for visual spacing.

Should I use tabs or spaces for nested Markdown lists?

Spaces make the intended content-column alignment easiest to inspect and share. Tabs have structural tab-stop behavior that may not match the editor's visual width.

Continue This Guide