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

> ## Agent Instructions
> Install the Courier skill before writing code: `npx skills add trycourier/courier-skills`. It carries the verified SDK shapes and the rules you cannot get wrong.
> Authenticate every request with `Authorization: Bearer <API_KEY>`. A workspace has several environments and each has its own keys, which are plain `pk_` strings with no environment prefix. Start with Test.
> Send with `client.send.message` from the Node SDK (`@trycourier/courier` v7 and later, where the client is the default import). Reference a template by its `nt_` id or its alias.
> A send accepts a bare Elemental element list, but storing content on a template requires the top-level elements wrapped in a channel element.
> To translate a template, write one locale at a time with `PUT /notifications/{id}/locales/{localeId}`, which merges into the existing translations. `PUT /notifications/{id}/content` and `PUT /notifications/{id}/elements/{elementId}` overwrite translations along with the content, so send each element's `id` and `locales` back, and first remove every `checksum` and any `locales` key that starts with an underscore.
> Templates and journeys can be built in the Courier app or created through the API. Either way they live in the workspace and are referenced by ID when you send.
> The hosted MCP server is https://mcp.courier.com. For a briefing on what Courier is and when to use it, read https://www.courier.com/llms.txt.
> Prefer the Guides tab for how-do-I questions and the Docs tab for how-does-it-behave questions. The API reference lives under /api-reference.

# Edit email HTML directly

> Edit a template's email HTML by hand and make it render in Gmail, Outlook, and Apple Mail, with inline CSS, table layouts, and MSO conditionals.

> [!NOTE]
>
> [How templates work](https://www.courier.com/docs/design/templates/overview.md) compares the designer with code.

When the visual designer's blocks aren't enough, edit a template's email HTML directly and format it to render across Gmail, Outlook, and Apple Mail.

## Prerequisites

* [An email template](https://app.courier.com/content/templates)
* Your HTML email markup

## Import and format the HTML

**1. Open the HTML editor**

Open the email template in the designer and click the code icon (`</>`) in the toolbar, then **Start editing**. Courier converts the current blocks to HTML and shows it in the editor.

> [!WARNING]
>
> **Editing HTML is one-directional.**\\
>
> Enabling code editing creates a new version, and switching back to the visual designer discards your HTML changes. Keep a copy of your HTML, or use version history to revert.

**2. Paste and format your HTML**

Paste your markup into the editor. It auto-formats on paste, highlights syntax, and wraps long lines. The email **subject** is edited separately in the subject field above the editor, so it is safe from your body changes.

**3. Add variables and logic**

Use Handlebars in the HTML to personalize each send. Reference the `data` payload (`{{order_id}}`), profile fields (`{{profile.email}}`), and use the full [Handlebars helpers](https://www.courier.com/docs/design/templates/variables.md) for logic and formatting:

```html theme={null}
{{#if premium_user}}
  <div class="premium-banner">Premium Member Benefits</div>
{{/if}}

{{#each items}}
  <tr>
    <td>{{capitalize this.name}}</td>
    <td>{{format this.price style="currency" currency="USD"}}</td>
  </tr>
{{/each}}
```

The preview panel renders your HTML with test data so you can check it before publishing.

**4. Make the HTML email-safe**

Email clients vary widely in their HTML and CSS support. When porting web HTML to email, work through this checklist:

* **Replace flexbox/grid with tables.** Use `<table>`/`<tr>`/`<td>` for layout, with `role="presentation"` on layout tables for accessibility.
* **Move all CSS inline.** External stylesheets and most `<style>` blocks are stripped (Gmail is the exception: it supports `<style>` in the `<head>`).
* **Replace `div` containers with table cells.** Outlook 2019 ignores `max-width` on `<div>`.
* **Set explicit pixel widths.** Percentages are unreliable in nested tables. Use a 600px max-width outer container and keep every section the same width.
* **Use `!important` on class-based styles.** Courier's MJML compiler generates inline styles that win by default, so your custom CSS classes need `!important` to override them (see [CSS class names](https://www.courier.com/docs/design/brands.md#css-class-names)).
* **Host images externally.** Use absolute URLs. Courier doesn't host images for `src` paths (the exception is [image blocks](https://www.courier.com/docs/design/templates/design-studio.md)).
* **Add MSO conditionals for Outlook.** Outlook uses Word's rendering engine and needs Outlook-specific table markup.

**5. Add Outlook compatibility**

Outlook 2019 and earlier ignore most CSS beyond basic font, color, margin, padding, and border. Wrap Outlook-specific table structure in MSO conditional comments:

```html theme={null}
<!--[if mso]>
<table role="presentation" width="600" style="width:600px;">
  <tr><td>
<![endif]-->
<table role="presentation" width="100%" style="max-width:600px;">
  <!-- Email content -->
</table>
<!--[if mso]></td></tr></table><![endif]-->
```

For a brand's MJML footer that needs Outlook support, inject the raw table with `<mj-raw>`. If MJML minification is enabled on your workspace, it can strip MSO comments from the compiled output. If your Outlook layout disappears after sending, [contact support](mailto:support@courier.com) to check whether minification is on for your workspace.

**6. Avoid unsupported CSS**

Modern CSS is unsupported or inconsistent in email. Avoid these without a tested fallback: `animation`/`transition` (use GIFs), `position: absolute/fixed`, `flex`/`grid` (use tables), `box-shadow` and `border-radius` (no Outlook), `opacity`, `calc()`, `filter`, pseudo-elements (`:hover`, `:before`), and `object-fit`. Design mobile-first at a 600px max width, since `@media` support is partial.

**7. Preview across clients**

Use the preview panel to check rendering with test data. Then run a [Device Preview](https://www.courier.com/docs/design/templates/device-preview.md) to screenshot the email in Gmail, Outlook, and Apple Mail themselves, in light and dark mode.
