Stop CKEditor from stripping CSS classes from tags

If you find that CKEditor is removing classes that you have added to your html the below should fix this. Incidentally I found that it allowed CSS classes to be added to <div> tags, but it was removing them from <p> tags.

Add the below code to the end of your CKEditors config.js file, which is found within the CKEditor library code.

CKEDITOR.config.allowedContent = true;

If you are using a skin such as 'Moono' you might find that the file is called ckeditor.config.js and that this is the file that needs to be changed rather than the default config.js. This file can be found in the root of the CKEditor module. 

Justin Chevallier

Justin Chevallier

Avid Drupal site builder & user for +9 years.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.