Title: Code
Published: June 7, 2026
Last modified: October 14, 2026

---

# Code

## In this article

 * [Attributes](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-code/?output_format=md#attributes)
 * [Supports](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-code/?output_format=md#supports)
 * [Block Markup](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-code/?output_format=md#block-markup)
 * [Source](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-code/?output_format=md#source)

 Display code snippets that respect your spacing and tabs.

 * **Name:** `core/code`
 * **Category:** [text](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/)
 * **API Version:** [3](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/)
 * **Block Type:** [Static](https://developer.wordpress.org/block-editor/getting-started/fundamentals/static-dynamic-rendering/)(
   saved in post content)

## 󠀁[Attributes](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-code/?output_format=md#attributes)󠁿

_Defined via the [`attributes`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/)
property in block.json._

  |  Attribute |  [Type](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#type-validation) |  [Default](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#default-value) |  Description |  
   |  `content` |  `rich-text` |  — |  [Source](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#value-source): `rich-text`. [Selector](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#value-source): `code`. [Role](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#role): `content` |

## 󠀁[Supports](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-code/?output_format=md#supports)󠁿

_Defined via the [`supports`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/)
property in block.json._

 * [`align`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#align):`"
   wide"`
 * [`anchor`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#anchor):`
   true`
 * [`background`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#background):
    - `backgroundImage`: `true`
    - `backgroundSize`: `true`
    - `gradient`: `true`
 * [`dimensions`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#dimensions):
    - `minHeight`: `true`
    - `minWidth`: `true`
 * [`typography`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography):
    - [`fontSize`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-fontsize):`
      true`
    - [`lineHeight`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-lineheight):`
      true`
 * [`spacing`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#spacing):
    - `margin`: `["top","bottom"]`
    - `padding`: `true`
 * [`color`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color):
    - [`text`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-text):`
      true`
    - [`background`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-background):`
      true`
    - [`gradients`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-gradients):`
      true`
 * [`shadow`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#shadow):`
   true`
 * [`interactivity`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#interactivity):
    - `clientNavigation`: `true`

## 󠀁[Block Markup](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-code/?output_format=md#block-markup)󠁿

This is a [**static block**](https://developer.wordpress.org/block-editor/getting-started/fundamentals/static-dynamic-rendering/).
The markup is saved directly in the post content.

    ```html
    <!-- wp:core/code -->
    <pre class="wp-block-code"><code>export default function MyButton() {
        return &lt;Button&gt;Click Me!&lt;/Button&gt;;
    }</code></pre>
    <!-- /wp:core/code -->
    ```

## 󠀁[Source](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-code/?output_format=md#source)󠁿

 * [block.json](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/code/block.json)(
   [reference](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/))
 * [Source directory](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/code/)—
   browse the `edit` and `save` source files, `index.php`, and more.

First published

June 7, 2026

Last updated

October 14, 2026

Edit article

[ Improve it on GitHub: Code ](https://github.com/WordPress/gutenberg/edit/trunk/packages/block-library/src/code/README.md)

[  Previous: Text Blocks](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/)

[  Next: Details](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-text/core-block-details/)