Do you feel annoying when CKEditor in Drupal keeps on changing your HTML code?

Sometimes you have HTML code that must be preserved in order to work. You are as the administrator, have no problems with code security. But when you paste your code, CKEditor in Drupal filters or alters your code structure, and it does not work as expected.

Some of the examples of HTML code altered:

  • <a> can't wrap around <div>
  • <img> tag can't stand alone, it is wrapped with <p>
  • empty <span>, <i>, <div> is not allowed
  • and etc ...

The workaround is quite simple:

  1. Please browse Admin - Configuration - Content Authoring - Text formats and editors, select + Add text format
  2. Then please create a new text format, "Full HTML withour CKeditor" for example, 
  3. Set it for administrator only, select editor as None, and don't check any options. Below is the screenshot of a Drupal 10 site:

  4. When edit your content, please select this new format option, then you are able to paste your HTML code without being modified by CKEditor

Good luck and have fun with Drupal.

Subscribe to our mailing list

* indicates required