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.