---
title: HTML sanitization
slug: html-sanitization
qid: Q5636099
snapshot: html-sanitization-640765-63f6469b0aa2e285
content_hash: 63f6469b0aa2e285a31b1c1972963d3e8de3b2047d343a7c6f8475ae552917a9
license: CC BY-SA 4.0
source: https://en.wikipedia.org/w/index.php?oldid=1357422320
tags: [23022637, 23118434, 23603337, 24043274, 43849222]
---

# HTML sanitization

> [!note] Provenance
> Snapshot `html-sanitization-640765-63f6469b0aa2e285` · content root `63f6469b0aa2e285…`
> Derived from <https://en.wikipedia.org/w/index.php?oldid=1357422320> · Licensed CC BY-SA 4.0

In data sanitization, HTML sanitization is the process of examining an HTML document and producing a new HTML document that preserves only whatever tags and attributes are designated "safe" and desired. HTML sanitization can be used to protect against attacks such as cross-site scripting (XSS) by sanitizing any HTML code submitted by a user.

In data sanitization, HTML sanitization is the process of examining an HTML document and producing a new HTML document that preserves only whatever tags and attributes are designated "safe" and desired. HTML sanitization can be used to protect against attacks such as cross-site scripting (XSS) by sanitizing any HTML code submitted by a user.
