4

We've unchecked the clean HTML feature on a few rich text fields but our attempts to add some html (span tags) keep getting cleaned out. Is there another setting we should be looking for?

3 Answers 3

3

I came upon this issue when wrapping copy with a span tag in order to style it differently. The span tag was removed when I saved the entry.

By design, Redactor removes span tags that don't have attributes. The fix is to edit the Redactor config file and add the removeWithoutAttr config as an empty array.

removeWithoutAttr: []

This prevents tags without attributes from being removed by Redactor.

2

If you are using a custom redactor config (defined in /craft/config/redactor) and it has allowedTags in the configuration, that list of allowed tags will need to include span

3
  • Sorry to circle back so late. Auto notifications weren't on. We don't have anything defined there, so that's not the case. Any other thoughts?
    – CFA
    Commented Sep 11, 2014 at 16:12
  • @Chris sorry, no other thoughts Commented Sep 11, 2014 at 19:31
  • Maybe the removeEmpty setting will help Commented Oct 26, 2014 at 2:55
1

Best I can figure it's either:

  1. A Redactor bug
  2. A known behavior and Redactor just really doesn't like <span></span> tags.

Even if you explicitly set Redactor's allowedTags config setting to include span, they will strip it out simply swapping between source and rendered view, whereas any other tag I set in that list will be allowed as expected.

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.