Markdown Code Blocks: Three Backticks (Fenced Code)
A code block shows several lines of code exactly as typed. Put three backticks on the line before and the line after. Write the language name straight after the first three to get coloured code on GitHub and in most editors.
The rule
Put three backticks ``` on the line before the code and on the line after it. Write the language name straight after the first three.
You type
```js
console.log("Hi")
```You get
console.log("Hi")Try it yourself
Make a python code block that contains: print("Hi")
Live preview
More examples
You type
```python
print("Hi")
print("Bye")
```You get
print("Hi")
print("Bye")A Python code block.
You type
```
plain text, kept exactly
spaces and all
```You get
plain text, kept exactly
spaces and allNo language name: still kept exactly as typed.
Common mistakes
You type
```python
print("Hi")Shows as
print("Hi")No closing backticks, so everything after it becomes code.
You type
``` python
print("Hi")
```Shows as
print("Hi")Works, but leave out the space: ```python is the usual form.
Where it works
GitHub, Obsidian, Notion, Discord, VS Code and nearly every modern Markdown app. Three tildes ~~~ work as well.
Keep it, not just learn it
The full course has 22 skills on five islands, short Missions that check your answers, and reviews a few days later so it sticks. Free, no sign-up.