How to Indent in Markdown: Spaces, Tabs, and Indented Blocks
If you are trying to indent in Markdown, the short answer is: plain Markdown has no paragraph-indent syntax. Leading spaces in a paragraph get stripped when the file renders, four leading spaces turn your paragraph into a code block, and the only reliable ways to show visible indentation are a non-breaking space, raw HTML where the renderer allows it, or correct list indentation. This page walks through all four situations and shows exactly what to type.
TL;DR: four indentation situations, four answers
| What you want | What you type | What renders |
|---|---|---|
| A visibly indented paragraph | Leading spaces | Nothing extra: Markdown strips leading spaces, so use a non-breaking space or raw HTML where the renderer allows it |
| Code that keeps its spacing | Four spaces or one tab | An indented code block; a fenced block is usually the clearer choice |
| Content deeper inside a list item | Indent to align with the item text | A continuation paragraph or a nested list |
| A second-line (hanging) indent | Raw HTML with CSS | Only where the renderer passes HTML through unchanged |
Why Markdown collapses leading spaces
Markdown treats leading spaces at the start of a line as insignificant for paragraph text. The cheat sheet on Markdown Guide lists the whole basic syntax, and indentation of ordinary paragraphs is simply not part of it; the Stack Overflow thread where writers ask why indenting their sections fails documents the same collapse in practice. That is by design: the format aims to keep documents readable as plain text, and to let the final stylesheet decide presentation such as indents.
So this input:
This line starts with four spaces.
can produce one of two very different results depending on context, which is the next section.
Indenting paragraphs: the workarounds
Because leading spaces collapse, "how to indent in markdown" is really a question about workarounds. The two options that show up in practice:
- Non-breaking space. Start the line with two
entities, or paste the actual non-breaking space character (U+00A0). Because the character is not an ordinary space, the renderer does not strip it. Caveat: whether an HTML entity is honored inside a paragraph depends on the renderer, so test it where you publish. - Raw HTML. Wrap the paragraph in a
<p>tag with a CSS indent, for example<p style="text-indent:2em">Your paragraph.</p>. The CSS text-indent property does the work. This only renders where raw HTML is allowed; platforms that sanitize input drop the style, which is why the Squarespace forum thread about second-line indents exists in the first place.
Both are renderer-dependent. The safe habit is to pick one, preview the result in the renderer you actually publish to, and keep using it consistently.
When indentation becomes a code block
Four leading spaces, or one tab, at the start of a block is how Markdown defines an indented code block. This is the most common "markdown indentation" surprise: you indent a paragraph for looks and the renderer prints it in a monospace box.
If you meant to write a paragraph, remove the leading spaces. If you meant to show code or preformatted text, prefer a fenced block:
```
This line is deliberately preformatted.
```
Fences make the intent explicit and survive copy-paste better than invisible whitespace. For the full fence syntax and inline code, see Markdown Code Blocks: Fences, Inline Code, and Language Hints.
Indenting content inside list items
Inside a list, indentation has a real meaning: it attaches content to an item. The rule is to indent continuation lines to align with the first character of the item's text:
- First item
A continuation paragraph aligned with the item text.
- A nested item, indented from its parent.
- Second item
Most modern renderers accept two spaces for hyphen lists because that matches the content column. Brett Terpstra's write-up on portable Markdown recommends four spaces as the choice recognized across every processor, and notes that four spaces are interchangeable with one tab for both indented code and nested lists. If your nested list does not indent, you most likely used fewer spaces than the content column requires. For the complete list rules, see Markdown Lists: Ordered, Unordered, and Nested Syntax.
Tabs vs spaces in Markdown
A tab character counts as one indentation level, equivalent to four spaces for code-block and list purposes. The problem is display: tab width is a viewer setting, not a property of your file. GitHub renders Markdown tabs at a width of 8, which is why the GitHub community discussion on tab indentation recommends spaces for predictable rendering, and Terpstra makes the same point: the display of tabs changes with the application and environment.

Pick spaces, be consistent, and your indentation will mean the same thing in every renderer.
Second-line and hanging indent: HTML only
A hanging indent, where the first line sits flush and every following line is indented, has no Markdown syntax. It needs CSS in raw HTML:
<p style="padding-left:2em; text-indent:-2em">First line flush, later lines indented.</p>
Treat this as renderer-dependent twice over: first, raw HTML blocks must be permitted; second, inline styles must survive sanitization. Check the rendered output before you rely on it. Blank-line and paragraph behavior in Markdown has its own rules, covered in Markdown Line Breaks: New Lines, Hard Breaks, and Blank Lines.
Frequently asked questions
How do I indent text in R Markdown? R Markdown uses standard Markdown rules, so leading spaces in a paragraph still collapse and four spaces still start a code block. Indent visible text with a non-breaking space or HTML, the same as anywhere else.
How do I indent when coding? Use a fenced code block. If the context forbids fences, four spaces or one tab produce an indented code block, which preserves your spacing.
Does Markdown support indentation? Only inside constructs that define it: nested lists, continuation paragraphs in list items, and indented code blocks. Free-standing paragraph indentation is not part of the syntax.
Keep indentation working everywhere
Three habits cover most cases: type leading spaces only where Markdown defines them, choose spaces over tabs, and use HTML workarounds only after previewing them in the renderer you publish to. And if you would rather edit files where the raw text and the rendered view sit side by side, Fylune is a local-first Markdown workspace built for exactly that.
Related guides
- Markdown Lists: Ordered, Unordered, and Nested Syntax
- Markdown Code Blocks: Fences, Inline Code, and Language Hints
- Markdown Line Breaks: New Lines, Hard Breaks, and Blank Lines
Sources
- Markdown Guide, Markdown Cheat Sheet
- Brett Terpstra, Write better Markdown
- GitHub Community, Markdown displayed does not support tab indentation, Discussion #48947
- MDN Web Docs, text-indent
- Squarespace Forum, 2nd line indent in Markdown block
- Stack Overflow, How do I indent items in the sections part of my markdown file
