> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/ueberdosis/tiptap/llms.txt
> Use this file to discover all available pages before exploring further.

# Code

> Mark text as inline code.

The Code extension allows you to mark text as inline code. Text is rendered as a `<code>` HTML element. This is different from the CodeBlock extension, which creates block-level code sections.

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install @tiptap/extension-code
  ```

  ```bash yarn theme={null}
  yarn add @tiptap/extension-code
  ```

  ```bash pnpm theme={null}
  pnpm add @tiptap/extension-code
  ```
</CodeGroup>

## Usage

```typescript theme={null}
import { Editor } from '@tiptap/core'
import Code from '@tiptap/extension-code'

const editor = new Editor({
  extensions: [
    Code,
  ],
})
```

## Keyboard Shortcuts

* `Mod-e` - Toggle inline code formatting

## Markdown Support

The extension supports markdown syntax for inline code:

* Type `` `text` `` to create inline code

## Configuration Options

<ParamField path="HTMLAttributes" type="Record<string, any>" default="{}">
  HTML attributes to add to the code element.

  ```typescript theme={null}
  Code.configure({
    HTMLAttributes: {
      class: 'my-code-class',
    },
  })
  ```
</ParamField>

## Commands

### setCode()

Set a code mark on the current selection.

```typescript theme={null}
editor.commands.setCode()
```

### toggleCode()

Toggle the code mark on the current selection.

```typescript theme={null}
editor.commands.toggleCode()
```

### unsetCode()

Remove the code mark from the current selection.

```typescript theme={null}
editor.commands.unsetCode()
```

## Behavior Notes

* The code mark excludes all other marks (configured with `excludes: '_'`)
* The code mark is exitable, meaning you can move the cursor out of it
* Other formatting marks cannot be applied inside inline code

## Source Code

View the source code on GitHub:

* [packages/extension-code](https://github.com/ueberdosis/tiptap/tree/main/packages/extension-code)
