Code Blocks

Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Mar 21, 2023
Contribute to Docs

Code blocks can be used to display multiple lines of code. They preserve formatting and provide syntax highlighting when possible.

Basic Usage

To create a basic code block, wrap the code with three backticks (```):

```
This is a code block.
```

The result will look like this:

This is a code block.

Syntax Highlighting

Optionally, a language can be specified for a code block to enable syntax highlighting. This can be done by appending the language to the starting backticks:

```js
console.log('Hello world');
```

The result will look like this:

console.log('Hello world');

All contributors

Looking to contribute?

Learn Markdown on Codecademy