On any Notion page, you can create a code block to display code so that it's broken out from the rest of your content and formatted by language. We support proper syntax coloring for a number of programing languages. For example, here's a Code block displaying JavaScript:
for (i = 0; i < 5; i++) {
text += "The number is " + i + "<br>";
}
Code blocks are useful to demonstrate programing concepts, share code with other developers, or maintain your own library of code snippets. They also make it a breeze to copy any amount of code to your clipboard to use elsewhere.
+
that appears to the left when you hover over a new line. Choose Code
and press enter
. Alternatively, type /code
and press enter
.⋮⋮
icon that appears as a handle to drag it.To eliminate side scrolling and create a line break at the edge of your code block:
•••
at the top right or ⋮⋮
on the left. You can also right click on the block itself.Wrap code
option.