Help: "Moodle strips out HTML I've added"
For example, you may want to add a simple Contact Form on your site. This can easily be done with an HTML Block or a Label, but if you have a custom theme (for example, Adaptable) that lets you add items into the Footer – you may prefer it there.
However, by default, Moodle will strip out some HTML that is added to areas that are not an HTML Block or a Label.
So instead of your contact form looking like this ?:
It could end up looking like this ?:
Firstly you should ensure you are pasting the HTML correctly. Following the Moodle Docs page for the default Atto text editor, you need to expand the menu (labelled 1) and click the HTML button (labelled 18) to get to the HTML view.
Then, you can paste in your HTML code and save changes. However, this is where you may find that Moodle will strip some of your HTML out and what you add will not look quite right!
The fix for this is to “Enable Trusted Content” which you can do via ‘Site Administrator -> Security -> Site Policy’ – and tick – “Enable Trusted Content”.
This will tell Moodle to allow Site Administrators to add code into areas that Moodle will normally attempt to “clean” to avoid the possibility of any malicious script being added to your site. Be sure to read the description carefully!
This will only apply to Site Administrators (unless you give other roles this ability!) so you should have site administrators you can trust and your password policy is enforced correctly, to help avoid any possibility of malicious content getting on the site.
Once this setting is enabled, you can then go back to where you added the HTML code and add it again (remove the current code and re-paste). When you save it this time, Moodle will no longer attempt to clean the code and you should see the content you were expecting.
If you have any issues with your site, such as this one, check out our Technical Support services and get in touch!