このページ:E メールデザイナーでメールコンテンツにカスタム CSS を追加し、高度なスタイル設定を行う方法、CSS を有効に維持する方法、適用されないスタイルのトラブルシューティング方法について説明します。
メールをデザインする際に、Journey OptimizerE メールデザイナー内で独自のカスタム CSS を直接追加できます。 この機能により、高度で特定のスタイル設定を適用して、コンテンツの外観に対する柔軟性と制御を高めることができます。
カスタム CSS の定義 define-custom-css
メールコンテンツにカスタム CSS を追加するには、次の手順に従います。
-
1 つ以上のコンポーネントを追加して、E メールデザイナーにコンテンツが定義されていることを確認します。
-
左側の ナビゲーションツリー または右側のパネルの上部にある「本文」を選択します。 右側に「CSS スタイル」セクションが表示されます。
{width="85%"}
note NOTE 「CSS スタイル」セクションは、エディターにコンテンツが既に存在する場合にのみ使用できます。 -
「カスタム CSS を追加」ボタンをクリックします。
note NOTE 「カスタム CSS を追加」ボタンは、「本文」を選択した場合にのみ使用できます。 ただし、コンテンツ内のすべてのコンポーネントにカスタム CSS スタイルを適用できます。 -
ポップアップ表示される専用のテキスト領域に CSS コードを入力します。 カスタム CSS が有効で、適切な構文に従っていることを確認します。 詳細情報
{width="65%"}
note NOTE コンテンツがロックされたテンプレートを使用する場合、コンテンツにカスタム CSS を追加できません。 ボタンのラベルが カスタム CSS を表示 に変わり、コンテンツに既に存在するカスタム CSS は読み取り専用になります。 -
カスタム CSS を保存し、カスタム CSS がコンテンツに正しく適用されていることを確認します。 該当しない場合は、トラブルシューティングの節を確認してください。
{width="85%"}
-
すべてのコンテンツを削除すると、セクションは非表示になり、以前に定義したカスタム CSS は適用されなくなります。
-
コンテンツをエディターに追加し直すと、「CSS スタイル」セクションが再表示されます。 カスタム CSS が再度適用されます。
有効な CSS の使用の確認 use-valid-css
「カスタム CSS を追加」テキスト領域に有効な CSS 文字列を入力できます。 適切に書式設定した CSS はコンテンツにすぐに適用されます。
有効な CSS の例を以下に示します。
| code language-css |
|---|
|
| code language-css |
|---|
|
無効な CSS を入力すると、CSS を保存できないことを示すエラーメッセージが表示されます。 無効な CSS の例を以下に示します。
<style> タグの使用は許可されていません。
| code language-html |
|---|
|
中括弧の欠落などの無効な構文は許可されていません:
| code language-css |
|---|
|
技術的な実装 implementation
次の例に示すように、カスタム CSS は、data-name="global-custom" 属性を持つ <style> タグの一部として <head> セクションの末尾に追加されます。 これにより、カスタムスタイルがコンテンツにグローバルに適用されます。
| code language-html |
|---|
|
カスタム CSS は、E メールデザイナーの 設定 パネルでは解釈または検証されません。 これは完全に独立しており、「カスタム CSS を追加」オプションを通じてのみ変更できます。
ガードレール - インポートしたコンテンツ guardrails-imported-content
E メールデザイナーに読み込んだコンテンツでカスタム CSS を使用する場合は、次の点を考慮します。
-
CSS を含む外部 HTML コンテンツを読み込む場合、そのコンテンツを変換しない限り、互換性モードになり、「CSS スタイル」セクションは使用できません。 既存のコンテンツの読み込みの詳細情報
-
「カスタム CSS を追加」オプションを通じて適用された CSS を含む、E メールデザイナーで作成したコンテンツを読み込む場合、以前に適用された CSS は同じオプションから表示および編集できます。
トラブルシューティング troubleshooting
カスタム CSS が適用されない場合は、以下の項目を確認します。
-
CSS が有効で、構文エラー(中括弧の欠落、プロパティ名の誤りなど)がないことを確認します。 方法についてはこちらを参照
-
CSS が
data-name="global-custom"属性を持つ<style>タグに追加されていることを確認します。 -
global-customスタイルのタグに属性data-disabledがtrueに設定されているかどうかを確認します。 この場合、カスタム CSS は適用されません。accordion 例: code language-html <style data-name="global-custom" type="text/css" data-disabled="true"> body: { color: red; } </style> -
コンテンツに適用されたテーマを含む、他の CSS ルールによって CSS が上書きされないようにします。
-
ブラウザーの開発者ツールを使用してコンテンツを検査し、CSS が正しいセレクターをターゲットにしていることを確認します。
-
優先されるようにするには、宣言に
!importantを追加することを考慮します。accordion 例: code language-css .acr-Form { background: red !important; }
-
This section contains structured knowledge intended to support interpretation, retrieval, and question answering related to this topic.
For complete understanding, this information should be combined with the documentation on this page. Neither source is intended to stand alone; the page describes the feature, while this section provides additional context that helps disambiguate terminology, intent, applicability, and constraints.
- TL;DR: The page explains how to add custom CSS to email content directly within the Journey Optimizer Email Designer for advanced and specific styling, how to make sure the CSS is valid, and what to check when the custom CSS is not applied.
Intents:
- Add custom CSS to email content in the Email Designer by selecting Body, either from the Navigation tree on the left or on top of the right pane, and using the Add Custom CSS button of the CSS styles section.
- Enter valid CSS in the Add custom CSS text area so that it can be saved and applied to the content.
- Find where the custom CSS is added in the HTML of the email content.
- Use custom CSS with content imported into the Email Designer.
- Troubleshoot custom CSS that is not applied to the content.
Glossary:
- CSS styles section (product-specific): The section that displays on the right of the Email Designer when Body is selected, and that contains the Add Custom CSS button.
- global-custom style tag (product-specific): The
<style>tag with thedata-name="global-custom"attribute, at the end of the<head>section of the email content, to which the custom CSS is added. This ensures that the custom styles are applied globally to the content.
Guardrails:
- The CSS styles section is only available when content is already present in the editor.
- The Add custom CSS button is only available when Body is selected. However, custom CSS styles can be applied to all the components inside the content.
- When using a template with locked content, you cannot add custom CSS to the content: the button label changes to View custom CSS and any custom CSS already present in the content is read-only.
- If you remove all content, the CSS styles section disappears and the previously defined custom CSS is no longer applied. When content is added back to the editor, the CSS styles section reappears and the custom CSS is applied again.
- If invalid CSS is entered, an error message is displayed, indicating that the CSS cannot be saved. Properly formatted CSS is immediately applied to the content.
- Users are responsible for the security of their custom CSS. Ensure that your CSS does not introduce vulnerabilities or conflicts with the existing content, and avoid using CSS that could unintentionally break the layout or functionality of the content.
- The custom CSS is not interpreted or validated by the Settings pane of the Email Designer. It is entirely independent and can only be modified through the Add Custom CSS option.
- If you import external HTML content including CSS, unless you convert that content, it is in Compatibility mode, where the CSS styles section is not available.
- If you import content created with the Email Designer including CSS applied through the Add custom CSS option, the CSS previously applied is visible and editable from the same option.
Terminology:
- Canonical name: Add custom CSS — variants: Add Custom CSS
FAQ:
- Why is the CSS styles section not available? The CSS styles section is only available when content is already present in the editor, so add at least one component first. For imported external HTML content that is not converted, the content is in Compatibility mode, where the CSS styles section is not available.
- Can custom CSS style components other than Body? Yes. The Add custom CSS button is only available when Body is selected, but you can apply custom CSS styles to all the components inside your content.
- What happens if I enter invalid CSS? An error message is displayed, indicating that the CSS cannot be saved.
- Can I add custom CSS when using a template with locked content? No. The button label changes to View custom CSS and any custom CSS already present in the content is read-only.
- Where is the custom CSS added in the email HTML? It is added to the end of the
<head>section as part of a<style>tag with thedata-name="global-custom"attribute. - What happens to the custom CSS if I remove all content? The CSS styles section disappears and the previously defined custom CSS is no longer applied. Adding content back makes the section reappear, and the custom CSS is applied again.
Troubleshooting:
-
Custom CSS is not applied: The page lists these checks:
- Ensure that your CSS is valid and free of syntax errors, such as missing braces or incorrect property names.
- Ensure that your CSS is being added to the
<style>tag with thedata-name="global-custom"attribute. - Check if the
global-customstyle tag has the attributedata-disabledset totrue. If this is the case, the custom CSS is not applied. - Ensure that your CSS is not overridden by other CSS rules, including any theme applied to your content. Use your browser developer tools to inspect the content and verify that your CSS is targeting the correct selectors, and consider adding
!importantto your declarations to ensure they take precedence.
Examples:
- Valid custom CSS for the Email Designer:
.acr-Form .spectrum-FieldLabel { width: 20%; }, or the media query@media only screen and (min-width: 600px) { .acr-paragraph-1 { width: 100% !important; } }. - Invalid custom CSS for the Email Designer: CSS wrapped in
<style>tags (for example<style type="text/css"> .acr-Form { width: 100%; } </style>) is not accepted, and invalid syntax such as missing braces (for examplebody { background: red;) is not accepted. - Use of
!importantin custom CSS:.acr-Form { background: red !important; }.
Related pages:
- For the editor in which custom CSS is added: Email Designer
- To add content to the Email Designer before defining custom CSS: component
- For templates in which custom CSS cannot be added: template with locked content
- For importing external HTML content into the Email Designer: Learn more on importing existing content
- For themes that can override custom CSS: theme
Personas:
- marketer: Can add custom CSS in the Email Designer by selecting Body and using the Add Custom CSS button. Can apply custom CSS styles to all the components inside the content. The page states that the CSS styles section is only available when content is already present in the editor. Where: “Define custom CSS”.
Onboarding:
- Level: Intermediate
- First minimal step: Ensure there is some content defined in the Email Designer by adding at least one component.
- Success check: Properly formatted CSS is immediately applied to the content.
- Previous: To have content defined in the Email Designer before adding custom CSS: component