Answer
HTML sanitization removes unsafe code from HTML supplied by a user. • It keeps only allowed tags and attributes. • It helps stop harmful scripts from running. • Use a trusted sanitizer instead of making one with simple text replacement.
💡 Simple Example
<p>Allow `<p>Hello</p>` but remove an unsafe `<script>` element.</p>
⚡ Quick Revision
Sanitization cleans untrusted HTML before it is displayed.