Ckeditor is stripping out all attributes from the source code.

This is the case I'm going through: When I add html code to the source of the Ckeditor, and then want to preview the changes by selecting source again, I find that no styling was taken. When I go back to check the source all styling attributes are removed and some HTML tags.

I found a way to save the content, without stripping by directly saving after pasting the html code in the source. But if I try to re-edit the content it strips all styling attributes and some html tags.

I am using Full HTML Text format, and did try previous versions of the ckeditor module. Also tried to modify the config.js file by adding "config.allowedContent = true;" as referred by the following post

<nav class="footer-wrapper"><section class="col-md-3">
<h3 class="block-title h5">
<ul class="list-unstyled"><li>
    <a href="/bio" title="">Biography</a>
    <a href="/timeline" title="Plans and Billing">Timeline</a>
    <a href="/quotes" target="_blank">Quotations</a>
    <a href="/philo" target="_blank" title="">Philosophy</a>

CKeditor Stripped HTMl:

    <li><a href="/bio" title="">Biography</a></li>
    <li><a href="/timeline" title="Plans and Billing">Timeline</a></li>
    <li><a href="/quotes" target="_blank">Quotations</a></li>
    <li><a href="/philo" target="_blank" title="">Philosophy</a></li>
<p>Intellectual Legacy</p>

Any way to resolve the following?

  • Which version of Drupal are you using? Commented Mar 8, 2016 at 13:45
  • Drupal 7.42 and latest ckeditor module and js
    – Hicham
    Commented Mar 8, 2016 at 14:06

1 Answer 1


You shouldn't really hack the config.js file. You can pass any custom configuration values through the admin:

  1. Go to /admin/config/content/ckeditor.

  2. Click on the "Edit" link next to the profile you are working with.

  3. Expand the "Advanced options" fieldset.

  4. Enter the following code in the "Custom JavaScript configuration":

    // Instruct CKEditor to disable the filter. You can also limit this to specific tags.
    config.allowedContent = true;
    // Allow p, div, li and ul tags to have any attributes attached to them.
    config.extraAllowedContent = 'p(*)[*]{*};div(*)[*]{*};li(*)[*]{*};ul(*)[*]{*}';

See docs for CKEDITOR.config.allowedContent and CKEDITOR.config.extraAllowedContent. If you are insterested in having this in every Drupal installation, check out my Drupal 7 installation profile.
The file in question is here.

Hope this helps.

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.