<p>There is a purify and a Clean-up option on a WYSIWYG field.</p>

<p><strong>Clean up HTML?</strong> – Whether Craft should run through some HTML cleanup routines when the field is saved, including removing all  tags, empty tags, and most style attributes.</p>

<p><strong>Purify HTML?</strong> – Whether the field should run submitted data through HTML Purifier before getting saved to the database, removing any potentially malicious code. Note that this is meant to be be used when accepting input in a Rich Text field from un-trusted sources.</p>

<p>Turning the purify off, let's you output HTML. That being said, I'm not sure of what you are trying to achieve but inserting raw HTML into a WYSYWIG field isn't really the way to go about things. Maybe if you share the bigger scope of the issue, we can look into a better approach of your problem.</p>

<p>source: <a href="https://craftcms.com/docs/rich-text-fields" rel="nofollow noreferrer">https://craftcms.com/docs/rich-text-fields</a></p>

CC BY-SA 3.0
2017-01-23T12:36:06.737Z
I want to allow anchors to be added in the body text so it is possible to refer/link to other parts of the content. As far as I know the Redactor WYSIWYG html editor does not have a function to add anchors (understandable because it will seldom be used) so it has to be added as raw HTML.

Like you pointed out, the Purify HTML option removes the 'id' and 'name' attribute. I would like to customize the HTML Purifier to allow these attributes but according to the post http://craftcms.stackexchange.com/questions/16366/how-to-customize-html-purifier this is not possible.
vinniecent
CC BY-SA 3.0
2017-01-23T12:36:52.517Z
Disabling the Purify HTML option fixes this issue for me.
vinniecent
CC BY-SA 3.0
2017-01-20T16:47:03.540Z
2017-01-20T16:47:03.540Z
Jan_dh
<p>How can I add an anchor element in my content. Both the id tag and name attribute are removed from the a tag by the WYSIWYG editor.</p>

<p>For example:</p>

<pre><code>&lt;p&gt;&lt;a name="my-anchor"&gt;My anchor with a name attribute&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a id="my-anchor"&gt;My anchor with an id attribute&lt;/a&gt;&lt;/p&gt;
</code></pre>

<p>is replaced by:</p>

<pre><code>&lt;p&gt;&lt;a&gt;My anchor with a name attribute&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a&gt;My anchor with an id attribute&lt;/a&gt;&lt;/p&gt;
</code></pre>

<redactor><wysiwyg>
Add Anchor in WYSIWYG editor
# Add Anchor in WYSIWYG editor

(Asked by: username_0 on 2017-01-20)

How can I add an anchor element in my content. Both the id tag and name attribute are removed from the a tag by the WYSIWYG editor.
For example:
My anchor with a name attribute
My anchor with an id attribute

is replaced by:
My anchor with a name attribute
My anchor with an id attribute

**Tags:** redactor, wysiwyg


---

## 1 answers

### Answer by username_1 on 2017-01-20. Score: 2 | Accepted answer

There is a purify and a Clean-up option on a WYSIWYG field.

**Clean up HTML?** – Whether Craft should run through some HTML cleanup routines when the field is saved, including removing all tags, empty tags, and most style attributes.

**Purify HTML?** – Whether the field should run submitted data through HTML Purifier before getting saved to the database, removing any potentially malicious code. Note that this is meant to be be used when accepting input in a Rich Text field from un-trusted sources.

Turning the purify off, let's you output HTML. That being said, I'm not sure of what you are trying to achieve but inserting raw HTML into a WYSYWIG field isn't really the way to go about things. Maybe if you share the bigger scope of the issue, we can look into a better approach of your problem.

source: <https://craftcms.com/docs/rich-text-fields>

> **Comments:**
> **username_0**: I want to allow anchors to be added in the body text so it is possible to refer/link to other parts of the content. As far as I know the Redactor WYSIWYG html editor does not have a function to add anchors (understandable because it will seldom be used) so it has to be added as raw HTML.  Like you pointed out, the Purify HTML option removes the 'id' and 'name' attribute. I would like to customize the HTML Purifier to allow these attributes but according to the post http://craftcms.stackexchange.com/questions/16366/how-to-customize-html-purifier this is not possible.  
> **username_0**: Disabling the Purify HTML option fixes this issue for me.  

---

