Tiny is changing the HTML unexpectedly although HTML is valid
Author: mstimvolCreated Sep 14, 2026Updated Sep 18, 2026
Labelstype: bug
## Provide detailed reproduction steps (if any)
We're about to use TinyMCE in Moodle 4.5 and 5.2, but we're facing some issues because TinyMCE edits the HTML unexpectedly. We're facing the following issues:
**HTML contains a simple image**
- Original: `
`
- TinyMCE: ` `
Tiny simply adding a whitespace between both `
` tag:
Besides this, Tiny is adding very often `
` tags. For example a simple `text` becomes `
text
`. Also when I've `some text` it becomes like this: `` But a span inside a link is valid and a `` not necessary:
I already discussed these issues in the Moodle developer chat and they told me that these issues are not related to Moodle itself, but to TinyMCE and I should open a bug issue here.
**Adding whitespaces**
- Original: `
` which is unnecessary and causes the page in some cases to break or not be aligned.
### ✔️ Expected result
TinyMCE should not add additional tags or remove them.
### ❌ Actual result
*What is the actual result of the above steps?*
For our customers it causes trouble because it affects the layout of the course and activity pages in Moodle.
## Other details
- Browser: Google Chrome
- OS: Windows 11
- First affected version: 8.2.2
- Worked in version: Never as far as we know
---
If you'd like to see this fixed sooner, add a reaction to this post.
Source: tinymce/tinymce