C.W.K.
Stream
Lesson 07 of 08 · published

Code — Inline & Fenced Blocks

~10 min · markdown, code, syntax-highlighting

Level 0Plaintext
0 XP0/64 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete

Three ways to mark up code

Inline code uses single backticks: `console.log()`. If your inline code itself contains a backtick, wrap with double backticks: ``code with `backticks` inside``.

Fenced code blocks use triple backticks with an optional language identifier for syntax highlighting:

```python
def greet(name):
    return f"Hello, {name}!"
```

Indented code blocks (4 spaces or 1 tab) are an older style. They produce no language hint and are easy to break by accident — prefer fenced blocks.

Language identifiers that matter

Common ones: python, javascript/js, typescript/ts, bash/shell, json, yaml, toml, html, css, sql, rust, go, java, c, cpp, diff, mermaid. Most renderers use these to choose a syntax-highlighting theme.

Use ~~~ when your code contains triple backticks: the alternate fence (~~~) lets you embed Markdown-with-backticks inside a code block without escaping every fence.

Code

Inline code·markdown
Use the `console.log()` function.
Double backticks for ``code with `backticks` inside``.
Fenced block with language·markdown
```python
def greet(name):
    return f"Hello, {name}!"
```

```bash
curl -s https://api.example.com | jq .
```
Tilde fence (when code contains ```)·markdown
~~~markdown
This fenced block can contain ```triple backticks``` literally.
~~~

External links

Exercise

Take a code snippet you wrote this week and embed it in a Markdown file three ways: as inline code, as an indented block, and as a fenced block with the right language identifier. Render and compare. Decide which style you'll commit to as your default.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.