En esta página: Aprenda a agregar CSS personalizado al contenido del correo electrónico en el Designer de correo electrónico para un estilo avanzado, a mantener el CSS válido y a solucionar problemas con los estilos que no se aplican.
Al diseñar los correos electrónicos, puede agregar su propio CSS personalizado directamente en Journey Optimizer Email Designer. Esta capacidad le permite aplicar estilos avanzados y específicos para obtener una mayor flexibilidad y control sobre el aspecto del contenido.
Definir CSS personalizado define-custom-css
Para añadir CSS personalizado al contenido del correo electrónico, siga los pasos a continuación.
-
Asegúrese de que haya contenido definido en el Designer de correo electrónico agregando al menos un componente.
-
Seleccione Cuerpo, ya sea en el árbol de navegación a la izquierda o en la parte superior del panel derecho. La sección estilos CSS se muestra a la derecha.
{width="85%"}
note NOTE La sección estilos CSS solo está disponible cuando el contenido ya está presente en el editor. -
Haga clic en el botón Agregar CSS personalizado.
note NOTE El botón Agregar CSS personalizado solo está disponible cuando se selecciona Cuerpo. Sin embargo, puede aplicar estilos CSS personalizados a todos los componentes del contenido. -
Introduzca su código CSS en el área de texto dedicada que aparece. Asegúrese de que CSS personalizado sea válido y siga la sintaxis adecuada. Más información
{width="65%"}
note NOTE Al usar una plantilla con contenido bloqueado, no se puede agregar CSS personalizado al contenido. La etiqueta del botón cambia a Ver CSS personalizado y cualquier CSS personalizado que ya esté presente en el contenido es de solo lectura. -
Guarde el CSS personalizado y compruebe que el CSS personalizado se aplica correctamente al contenido. Si no es así, consulte la sección Solución de problemas.
{width="85%"}
-
Si elimina todo el contenido, la sección desaparece y ya no se aplica el CSS personalizado definido anteriormente.
-
Vuelva a agregar contenido al editor para que vuelva a aparecer la sección estilos CSS. Se vuelve a aplicar el CSS personalizado.
Asegúrese de utilizar CSS válido use-valid-css
Puede introducir cualquier cadena CSS válida en el área de texto Agregar CSS personalizado. El CSS con el formato correcto se aplica inmediatamente al contenido.
A continuación se muestran ejemplos de CSS válido.
| code language-css |
|---|
|
| code language-css |
|---|
|
Si se introduce un CSS no válido, se muestra un mensaje de error que indica que el CSS no se puede guardar. A continuación se muestran ejemplos de CSS no válido.
No se acepta el uso de etiquetas <style>:
| code language-html |
|---|
|
No se acepta sintaxis no válida como llaves que faltan:
| code language-css |
|---|
|
Implementación técnica implementation
Su CSS personalizado se agrega al final de la sección <head> como parte de una etiqueta <style> con el atributo data-name="global-custom", como en el ejemplo siguiente. Esto garantiza que los estilos personalizados se apliquen globalmente al contenido.
| code language-html |
|---|
|
El panel Configuración de Designer de correo electrónico no interpreta ni valida la CSS personalizada. Es totalmente independiente y solo se puede modificar mediante la opción Agregar CSS personalizado.
Protecciones: contenido importado guardrails-imported-content
Si desea utilizar CSS personalizado con contenido importado en el Designer de correo electrónico, tenga en cuenta lo siguiente:
-
Si importa contenido externo de HTML, incluido CSS, a menos que convierta ese contenido, estará en modo de compatibilidad, donde la sección estilos CSS no está disponible. Más información sobre cómo importar contenido existente
-
Si se importa contenido creado con el Designer de correo electrónico, incluido CSS aplicado a través de la opción Agregar CSS personalizado, el CSS aplicado anteriormente se podrá ver y editar desde la misma opción.
Resolución de problemas troubleshooting
Si no se aplica el CSS personalizado, tenga en cuenta las siguientes opciones.
-
Asegúrese de que el CSS sea válido y esté libre de errores de sintaxis (como llaves que faltan, nombres de propiedad incorrectos). Descubra cómo
-
Asegúrese de que su CSS se agrega a la etiqueta
<style>con el atributodata-name="global-custom". -
Compruebe si la etiqueta de estilo
global-customtiene el atributodata-disabledestablecido entrue. En este caso, no se aplica el CSS personalizado.accordion Por ejemplo: code language-html <style data-name="global-custom" type="text/css" data-disabled="true"> body: { color: red; } </style> -
Asegúrese de que otras reglas CSS no anulen su CSS, incluido cualquier tema aplicado al contenido.
-
Utilice las herramientas para desarrolladores del navegador para inspeccionar el contenido y comprobar que el CSS está dirigido a los selectores correctos.
-
Considere agregar
!importanta sus declaraciones para asegurarse de que tengan prioridad.accordion Por ejemplo: 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