Markdown syntax: Code blocks
Indented code blocks
An indented code block consists of lines indented by four spaces or a tab.
If the code block is in a list, the number of spaces is counted from the alignment with the text of the parent element.
If the code block is in a blockquote, the first space is part of the blockquote tag. Therefore five spaces are required.
Examples
••••This is a code block (indented by 4 spaces)
→This is a code block (indented by 1 tab)
1. Ordered list item
•••••••3 spaces for alignment and 4 for code block
* Unordered list item
••••••2 spaces for alignment and 4 for code block
>•••••5 spaces are required in a blockquote
Fenced code blocks
A fenced code block consists of a block preceded and followed by a line containing either three or more backticks ` or three or more tilde characters ~.
Optionally, an info string can be appended to the first line. It is used for syntax highlighting and is not rendered.
Examples
```
This is a fenced code block
```
~~~ Pascal
Fenced code block with info string
~~~
Code span
A code span begins and ends with a backtick `. If the code itself contains backticks, wrap it with more backticks.
Examples
This is a text with a `code span` in it.
This is a text with a ``code`span`` with backtick in it.