Within the editor it seems html is validated so that multiple elements cannot be placed within a tags. I want to allow markup like below:

<a href="#"><h2>Category</h2><img src="logo.png" /><p>Some text...</p></a>

This however always ends up like so:

<a href="#"><h2>Category</h2></a><img src="logo.png" /><p>Some text...</p>

I have seen posts about this however am unsure how to modify valid_elements or valid_child_elements within magento 2.


There is also this but this applies to Magento 1 :


So far have tried looking at module-backend/view/adminhtml/templates/widget/form/element.phtml and lib/web/tiny_mce/tiny_mce_src.js as this is the only place i could see configs like this but had no luck.

How can i override these settings with Magento 2?

  • starting point js/mage/adminhtml/wysiwyg/tiny_mce/setup.js
    – jscar
    Oct 30, 2017 at 13:07
  • Is that the Magento 1 path?
    – harri
    Oct 30, 2017 at 13:10
  • Yes it is. Sorry, should have said that.
    – jscar
    Oct 30, 2017 at 13:42

2 Answers 2


Check my question on TinyMCE Community.

There is the answer: TinyMCE views anchor links as an inline element and will not allow block elements to be placed inside of them. This is a limitation of the current TinyMCE object model. As a workaround, you could use a span inside the anchor tag and style the text as needed based on the span.


I encountered the same problem, solved it by follow way.

Navigate to Dashboard > store > settings > Configuration > general > content management > WYSIWYG Options > Enable WYSIWYG Editor, choose Disabled by Default.

After setting, you could still use WYSIWYG Editor in catalog content, but it is not default now, it will not affect your html codes in page or block unless you click the Show/Hide Editor button.

  • I solved my problems with tinymce in Magento this way too. ;-) Jan 23, 2019 at 10:55
  • THANK YOU +1000
    – appl3r
    May 11, 2020 at 11:10
  • Helped me too. thanks Dec 1, 2020 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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