CKEditor automatically strips classes from div in Drupal

ckeditor-issue

Using CKEditor as a back end editor on my website. It is driving me round the bend though as it seems to want to change the code to how it sees fit whenever I press the source button.

For example if I hit source and create a <div>…

<div class=”myclass”>some content</div>
It then for no apparent reason strips the class from the <div>, so when I hit source again it has been changed to…

<div>some content</div>

Soln 1.
Follow this given step to resolve this issue.
Go to “Admin >> Configuration >> CKEditor”; under Profiles, choose your profile (e.g. Full).

Edit that profile, and on “Advanced Options >> Custom JavaScript configuration” add config.allowedContent = true;.

Soln 2.
The easiest solution is going to the config.js and setting:
config.allowedContent = true;

Leave a Reply

Your email address will not be published. Required fields are marked *