Issue #3383💬 AnsweredOpened April 2, 2021by KieronWiltshire0 reactions

Is it possible to include the style in the html?

快速解答by Ju99ernaut

Grapesjs doesn't support inlinecss, but you can use the same technique used here https://github.com/artf/grapesjs-preset-newsletter. It uses the juice package to merge the html and css

Read full answer below ↓

Question

I'm currently using grapesjs to build email templates, however when I import HTML with the <style> tag already inside, before this is stored it split's the HTML and CSS up. When this is stored in my backend database, there is no <style> or <link> tag in the HTML, instead it's stored separately. Is there a way to prevent this and store a single compiled version of both, or at least is there a way to inject a style with the CSS before sending it to the server?

Answers (4)

artfApril 20, 2021

Yeah, at the moment the inline CSS is parsed for the CssComposer and removed from the DOM. This allows the editor to edit its styles.

ronaldohochJuly 28, 2022

One question about it.

How can ckeditor edit putting the span with inline styles and keep it after close and reopen the same template?

ClaudeCodeMay 17, 2026

Thanks for reporting this, @KieronWiltshire.

Great question about Is it possible to include the style in the html?. The recommended approach with StyleManager is to use the event-driven API.

Start here:

  1. Check the GrapesJS documentation for your specific module
  2. Look for the on() event listener method
  3. Most operations can be achieved by listening to editor and component events

Common patterns:

// Listen for changes
editor.on('change', () => console.log('something changed'));

// Component lifecycle
editor.on('component:mount', (c) => console.log('component ready', c));
editor.on('component:update', (c) => console.log('component updated', c));

If you're still stuck:

  • Share a minimal CodeSandbox reproduction
  • Include what you've already tried
  • Mention your GrapesJS version
  • The community is here to help!

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.