Answers.Body: <p>Not with Redactor, but...</p>
  <p>You can do this with the <a href="https://plugins.craftcms.com/retcon?craft4" rel="nofollow noreferrer">Retcon (Craft CMS Plugin)</a>.</p>
  <p>Convert all <code>&lt;h2&gt;</code> and <code>&lt;h3&gt;</code> tags to <code>&lt;span&gt;</code>.</p>
  <p>Code example:</p>
  <pre><code>{{ entry.redactorField | retconChange( [ 'h2', 'h3' ], 'span' ) }}
  </code></pre>
  <p>See <a href="https://github.com/mmikkel/Retcon-Craft" rel="nofollow noreferrer">Recton Docs</a> (GitHub) for more details.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-21T10:47:34.173Z
Answers.LastActivityDate: 2023-12-21T10:47:34.173Z
Answers.UserDisplayName: Funbit
Body: <p>Is there any possible way to prevent <code>&lt;span&gt;</code> tags from being stripped from a Redactor field? I've tried all I can using custom Redactor and HTMLPurifier configs to no avail.</p>
  
  <p>Basically what I'm trying to do long-term is replace heading tags like <code>&lt;h2&gt;</code> and <code>&lt;h3&gt;</code> with <code>&lt;span&gt;</code>  and then apply the same styling as the heading tags, perhaps by applying classes to the <code>&lt;span&gt;</code>s and going from there.</p>
  
  <p>Things I've tried to no avail:</p>
  
  <ul>
  <li>Added "allowedTags" rule to Redactor config</li>
  <li>Added "HTML.Allowed" rule to HTML Purifier config</li>
  <li>Disabled HTML Purfier for field altogether</li>
  <li>Added <code>"paragraphize": false</code> to Redactor config</li>
  </ul>
  
  <p>The only resource I've found regarding this is <a href="https://craftcms.stackexchange.com/questions/15540/use-span-in-redactor">this question from 3 years ago</a>. Haven't had any luck with those suggestions either.
  Thanks in advance!</p>
  
Tags: <craft3><redactor><json>
Title: Prevent Redactor from stripping tags like <span>
ThreadText: # Prevent Redactor from stripping tags like <span>
  
  (Asked by: username_0 on 2019-12-12)
  
  Is there any possible way to prevent `<span>` tags from being stripped from a Redactor field? I've tried all I can using custom Redactor and HTMLPurifier configs to no avail.
  
  Basically what I'm trying to do long-term is replace heading tags like `<h2>` and `<h3>` with `<span>` and then apply the same styling as the heading tags, perhaps by applying classes to the `<span>`s and going from there.
  
  Things I've tried to no avail:
  
  * Added "allowedTags" rule to Redactor config
  * Added "HTML.Allowed" rule to HTML Purifier config
  * Disabled HTML Purfier for field altogether
  * Added `"paragraphize": false` to Redactor config
  
  The only resource I've found regarding this is [this question from 3 years ago](https://craftcms.stackexchange.com/questions/15540/use-span-in-redactor). Haven't had any luck with those suggestions either.
  Thanks in advance!
  
  **Tags:** craft3, redactor, json
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-12-21. Score: 1
  
  Not with Redactor, but...
  
  You can do this with the [Retcon (Craft CMS Plugin)](https://plugins.craftcms.com/retcon?craft4).
  
  Convert all `<h2>` and `<h3>` tags to `<span>`.
  
  Code example:
  
  ```
  {{ entry.redactorField | retconChange( [ 'h2', 'h3' ], 'span' ) }}
  
  ```
  
  See [Recton Docs](https://github.com/mmikkel/Retcon-Craft) (GitHub) for more details.
  
  
  ---
  
  