Markdown Code Blocks
Last updated: 2026-10-14
Code Blocks CommonMark core
Wrap code in triple backticks with a language tag to get a highlighted fenced code block. The single most important syntax for technical docs — every code sample on this site uses it.
| Group | Basic: Block |
|---|---|
| Spec level | CommonMark core |
| Spec version | CommonMark 0.31.2 + GFM |
📝 Syntax
```js
your code
```
▶ Live Example
Edit Markdown on the left, see the result on the right
💡 Key points
💡 Tip The language tag enables highlighting: js, python, css, html and more.
⚠️ Warning Markdown inside a fence is not parsed — great for showing literal syntax.
❓ FAQ
Q What if the code contains backticks?
A Use a longer outer fence: if the code has 3 backticks, open with 4 or more.
Q Indented or fenced block?
A Always fenced: language tags, no 4-space indent dance, safer inside lists.
Q Do tildes ~~~ also open a fence?
A Yes — ~~~ is a standard fence and immune to backtick conflicts in content.