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
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.
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
-
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?– CFACommented Sep 11, 2014 at 16:12
-
-
Best I can figure it's either:
- A Redactor bug
- 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.