I am using TinyMCE4 in my Magento admin panel. I want to allow <style></style> for my CMS pages and blocks while editing. I am able to add <style> in my CMS pages and Blocks but once the block or page is saved, the <style> tag gets hidden.

I have checked with database that it stores my tag with other data and my frontend also reflects the stylesheet. When I try to edit a page or static block again, the style tag is not visible to admin.

I have used

inline_styles : 1, // or true
keep_styles : 1, // or true

in my tinymcs4Adapter.js file but still the tags are not showing in editor area.

NOTE: If I use tinyMCE3 as my editor, <style> tags are displayed correctly but I don't want to use it as its deprecated.

1 Answer 1


TinyMCE disabled the ability to add them outside of the tags, so <style> tags are not valid XHTML, For this you will have to add style tags to the valid children configuration:

valid_children : "+body[style]"

So for magento you need to replace the code in lib/web/tiny_mce_4/tinymce.min.js:

to :


with :


now run the commands

php bin/magento s:s:d -f

php bin/magento c:f

check in the below URL: https://www.tiny.cloud/docs-3x//reference/configuration/Configuration3x@valid_children/

NOTE : It will render the css in admin, so admin layout will affect as per css


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.