Indented Code Blocks in Markdown

From the Markdown cheat sheet ยท Code ยท verified Aug 2026

Indented Code Blocks

Create a code block with four leading spaces.

markdown
const port = 3000
    startServer(port)
๐Ÿ“Œ Indent every code line by at least four spaces
๐Ÿ” Indented blocks cannot declare a language hint
โš ๏ธ Indentation may be interpreted as list nesting
๐ŸŽฏ Use fenced blocks for most documentation
indented-codecode-blocksindentation

Continue with Markdown

Save the full cheat sheet or work through every related task.

More Markdown tasks

Back to the full Markdown cheat sheet