Default sanitizer configuration
HTML Sanitizer API
HTML Sanitizer API
The default sanitizer configuration defines the configuration returned by the [`Sanitizer()` constructor](/docs/Web/API/Sanitizer/Sanitizer) if no `configuration` is passed as an argument.
This same configuration is implicitly used if you call the [safe sanitization methods](/docs/Web/API/HTML_Sanitizer_API#sanitization_methods), such as Element.setHTML(), ShadowRoot.setHTML(), and Document.parseHTML(), without specifying a custom sanitizer.
This configuration removes the following sorts of items:
1. Those that are known to be XSS-unsafe:
- base, embed, frame, iframe, object, script, and use.
- All event handler content attributes, such as `onafterprint`, `onbeforeinput`, and so on.
2. Items that might be used in clickjacking, spoofing, or other attacks.
3. Deprecated items.
4. Comments and `data-*` attributes.
It therefore provides a sanitizer with a minimal attack surface, which is still suitable for the majority of sanitization use cases.
> [!NOTE]
> Calling Sanitizer.removeUnsafe(), or passing a custom sanitizer to the safe sanitization method, only removes the XSS-unsafe items.
> It does not remove the additional items, comments, and `data-*` attributes.
The following sections list all the elements, with a ✓ mark indicating those that are _allowed_ by the default configuration (the ❌ therefore indicates those that will be removed).
The "Additional allowed attributes" column lists the attributes that are allowed for the corresponding elements; any other attributes on the element would be removed (unless allowed by the global attributes).
The [Global attributes](#global_attributes) section lists the attributes that are allowed on all elements (the attributes that are not removed when the configuration is used).
## HTML elements
| Element | Allowed | Additional allowed attributes |
| -------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| a | ✓ | [`href`](/docs/Web/HTML/Reference/Elements/a#href), [`hreflang`](/docs/Web/HTML/Reference/Elements/a#hreflang), [`type`](/docs/Web/HTML/Reference/Elements/a#type) |
| abbr | ✓ | |
| acronym | ❌ | |
| address | ✓ | |
| area | ❌ | |
| article | ✓ | |
| aside | ✓ | |
| audio | ❌ | |
| b | ✓ | |
| base | ❌ | |
| bdi | ✓ | |
| bdo | ✓ | |
| big | ❌ | |
| blockquote | ✓ | [`cite`](/docs/Web/HTML/Reference/Elements/blockquote#cite) |
| body | ✓ | |
| br | ✓ | |
| button | ❌ | |
| canvas | ❌ | |
| caption | ✓ | |
| center | ❌ | |
| cite | ✓ | |
| code | ✓ | |
| col | ✓ | [`span`](/docs/Web/HTML/Reference/Elements/col#span) |
| colgroup | ✓ | [`span`](/docs/Web/HTML/Reference/Elements/colgroup#span) |
| data | ✓ | [`value`](/docs/Web/HTML/Reference/Elements/data#value) |
| datalist | ❌ | |
| dd | ✓ | |
| del | ✓ | [`cite`](/docs/Web/HTML/Reference/Elements/del#cite), [`datetime`](/docs/Web/HTML/Reference/Elements/del#datetime) |
| details | ❌ | |
| dfn | ✓ | |
| dialog | ❌ | |
| dir | ❌ | |
| div | ✓ | |
| dl | ✓ | |
| dt | ✓ | |
| em | ✓ | |
| embed | ❌ | |
| fencedframe | ❌ | |
| fieldset | ❌ | |
| figcaption | ✓ | |
| figure | ✓ | |
| font | ❌ | |
| footer | ✓ | |
| form | ❌ | |
| frame | ❌ | |
| frameset | ❌ | |
| <h1> – <h6> | ✓ | |
| head | ✓ | |
| header | ✓ | |
| hgroup | ✓ | |
| hr | ✓ | |
| html | ✓ | |
| i | ✓ | |
| iframe | ❌ | |
| img | ❌ | |
| input | ❌ | |
| ins | ✓ | [`cite`](/docs/Web/HTML/Reference/Elements/ins#cite), [`datetime`](/docs/Web/HTML/Reference/Elements/ins#datetime) |
| kbd | ✓ | |
| label | ❌ | |
| legend | ❌ | |
| li | ✓ | [`value`](/docs/Web/HTML/Reference/Elements/li#value) |
| link | ❌ | |
| main | ✓ | |
| map | ❌ | |
| mark | ✓ | |
| marquee | ❌ | |
| menu | ✓ | |
| meta | ❌ | |
| meter | ❌ | |
| nav | ✓ | |
| nobr | ❌ | |
| noembed | ❌ | |
| noframes | ❌ | |
| noscript | ❌ | |
| object | ❌ | |
| ol | ✓ | [`reversed`](/docs/Web/HTML/Reference/Elements/ol#reversed), [`start`](/docs/Web/HTML/Reference/Elements/ol#start), [`type`](/docs/Web/HTML/Reference/Elements/ol#type) |
| optgroup | ❌ | |
| option | ❌ | |
| output | ❌ | |
| p | ✓ | |
| param | ❌ | |
| picture | ❌ | |
| plaintext | ❌ | |
| pre | ✓ | |
| progress | ❌ | |
| q | ✓ | |
| rb | ❌ | |
| rp | ✓ | |
| rt | ✓ | |
| rtc | ❌ | |
| ruby | ✓ | |
| s | ✓ | |
| samp | ✓ | |
| script | ❌ | |
| search | ✓ | |
| section | ✓ | |
| select | ❌ | |
| selectedcontent | ❌ | |
| slot | ❌ | |
| small | ✓ | |
| source | ❌ | |
| span | ✓ | |
| strike | ❌ | |
| strong | ✓ | |
| style | ❌ | |
| sub | ✓ | |
| summary | ❌ | |
| sup | ✓ | |
| table | ✓ | |
| tbody | ✓ | |
| td | ✓ | [`colspan`](/docs/Web/HTML/Reference/Elements/td#colspan), [`headers`](/docs/Web/HTML/Reference/Elements/td#headers), [`rowspan`](/docs/Web/HTML/Reference/Elements/td#rowspan) |
| template | ❌ | |
| textarea | ❌ | |
| tfoot | ✓ | |
| th | ✓ | [`abbr`](/docs/Web/HTML/Reference/Elements/th#abbr), [`colspan`](/docs/Web/HTML/Reference/Elements/th#colspan), [`headers`](/docs/Web/HTML/Reference/Elements/th#headers), [`rowspan`](/docs/Web/HTML/Reference/Elements/th#rowspan), [`scope`](/docs/Web/HTML/Reference/Elements/th#scope) |
| thead | ✓ | |
| time | ✓ | [`datetime`](/docs/Web/HTML/Reference/Elements/time#datetime) |
| title | ✓ | |
| tr | ✓ | |
| track | ❌ | |
| tt | ❌ | |
| u | ✓ | |
| ul | ✓ | |
| var | ✓ | |
| video | ❌ | |
| wbr | ✓ | |
| xmp | ❌ | |
## SVG elements
| Element | Allowed | Additional allowed attributes |
| ------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| a | ✓ | href, [`hreflang`](/docs/Web/HTML/Reference/Elements/a#hreflang), type |
| animate | ❌ | |
| animateMotion | ❌ | |
| animateTransform | ❌ | |
| circle | ✓ | cx, cy, pathLength, r |
| clipPath | ❌ | |
| defs | ✓ | |
| desc | ✓ | |
| ellipse | ✓ | cx, cy, pathLength, rx, ry |
| feBlend | ❌ | |
| feColorMatrix | ❌ | |
| feComponentTransfer | ❌ | |
| feComposite | ❌ | |
| feConvolveMatrix | ❌ | |
| feDiffuseLighting | ❌ | |
| feDisplacementMap | ❌ | |
| feDistantLight | ❌ | |
| feDropShadow | ❌ | |
| feFlood | ❌ | |
| feFuncA | ❌ | |
| feFuncB | ❌ | |
| feFuncG | ❌ | |
| feFuncR | ❌ | |
| feGaussianBlur | ❌ | |
| feImage | ❌ | |
| feMerge | ❌ | |
| feMergeNode | ❌ | |
| feMorphology | ❌ | |
| feOffset | ❌ | |
| fePointLight | ❌ | |
| feSpecularLighting | ❌ | |
| feSpotLight | ❌ | |
| feTile | ❌ | |
| feTurbulence | ❌ | |
| filter | ❌ | |
| foreignObject | ✓ | height, width, x, y |
| g | ✓ | |
| image | ❌ | |
| line | ✓ | pathLength, x1, x2, y1, y2 |
| linearGradient | ❌ | |
| marker | ✓ | markerHeight, markerUnits, markerWidth, orient, preserveAspectRatio, refX, refY, viewBox |
| mask | ❌ | |
| metadata | ✓ | |
| mpath | ❌ | |
| path | ✓ | d, pathLength |
| pattern | ❌ | |
| polygon | ✓ | pathLength, points |
| polyline | ✓ | pathLength, points |
| radialGradient | ❌ | |
| rect | ✓ | height, pathLength, rx, ry, width, x, y |
| script | ❌ | |
| set | ❌ | |
| stop | ❌ | |
| style | ❌ | |
| svg | ✓ | height, preserveAspectRatio, viewBox, width, x, y |
| switch | ❌ | |
| symbol | ❌ | |
| text | ✓ | dx, dy, lengthAdjust, rotate, textLength, x, y |
| textPath | ✓ | lengthAdjust, method, path, side, spacing, startOffset, textLength |
| title | ✓ | |
| tspan | ✓ | dx, dy, lengthAdjust, rotate, textLength, x, y |
| use | ❌ | |
| view | ❌ | |
## MathML elements
| Element | Allowed | Additional allowed attributes |
| ----------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| annotation | ❌ | |
| annotation-xml | ❌ | |
| maction | ❌ | |
| math | ✓ | |
| menclose | ❌ | |
| merror | ✓ | |
| mfenced | ❌ | |
| mfrac | ✓ | |
| mi | ✓ | |
| mmultiscripts | ✓ | |
| mn | ✓ | |
| mo | ✓ | [`fence`](/docs/Web/MathML/Reference/Element/mo#fence), [`form`](/docs/Web/MathML/Reference/Element/mo#form), [`largeop`](/docs/Web/MathML/Reference/Element/mo#largeop), [`lspace`](/docs/Web/MathML/Reference/Element/mo#lspace), [`maxsize`](/docs/Web/MathML/Reference/Element/mo#maxsize), [`minsize`](/docs/Web/MathML/Reference/Element/mo#minsize), [`movablelimits`](/docs/Web/MathML/Reference/Element/mo#movablelimits), [`rspace`](/docs/Web/MathML/Reference/Element/mo#rspace), [`separator`](/docs/Web/MathML/Reference/Element/mo#separator), [`stretchy`](/docs/Web/MathML/Reference/Element/mo#stretchy), [`symmetric`](/docs/Web/MathML/Reference/Element/mo#symmetric) |
| mover | ✓ | [`accent`](/docs/Web/MathML/Reference/Element/mover#accent) |
| mpadded | ✓ | [`depth`](/docs/Web/MathML/Reference/Element/mpadded#depth), [`height`](/docs/Web/MathML/Reference/Element/mpadded#height), [`lspace`](/docs/Web/MathML/Reference/Element/mpadded#lspace), [`voffset`](/docs/Web/MathML/Reference/Element/mpadded#voffset), [`width`](/docs/Web/MathML/Reference/Element/mpadded#width) |
| mphantom | ✓ | |
| mprescripts | ✓ | |
| mroot | ✓ | |
| mrow | ✓ | |
| ms | ✓ | |
| mspace | ✓ | [`depth`](/docs/Web/MathML/Reference/Element/mspace#depth), [`height`](/docs/Web/MathML/Reference/Element/mspace#height), [`width`](/docs/Web/MathML/Reference/Element/mspace#width) |
| msqrt | ✓ | |
| mstyle | ✓ | |
| msub | ✓ | |
| msubsup | ✓ | |
| msup | ✓ | |
| mtable | ✓ | |
| mtd | ✓ | [`columnspan`](/docs/Web/MathML/Reference/Element/mtd#columnspan), [`rowspan`](/docs/Web/MathML/Reference/Element/mtd#rowspan) |
| mtext | ✓ | |
| mtr | ✓ | |
| munder | ✓ | [`accentunder`](/docs/Web/MathML/Reference/Element/munder#accentunder) |
| munderover | ✓ | [`accent`](/docs/Web/MathML/Reference/Element/munderover#accent), [`accentunder`](/docs/Web/MathML/Reference/Element/munderover#accentunder) |
| semantics | ✓ | |
## Global attributes
The default configuration allows the following attributes on **all** elements.
### HTML global attributes
- [`dir`](/docs/Web/HTML/Reference/Global_attributes/dir)
- [`lang`](/docs/Web/HTML/Reference/Global_attributes/lang)
- [`title`](/docs/Web/HTML/Reference/Global_attributes/title)
### MathML global attributes
- `displaystyle`
- [`mathbackground`](/docs/Web/MathML/Reference/Global_attributes/mathbackground)
- [`mathcolor`](/docs/Web/MathML/Reference/Global_attributes/mathcolor)
- [`mathsize`](/docs/Web/MathML/Reference/Global_attributes/mathsize)
- [`scriptlevel`](/docs/Web/MathML/Reference/Global_attributes/scriptlevel)
### SVG attributes
- alignment-baseline
- baseline-shift
- clip-path
- clip-rule
- color
- color-interpolation
- cursor
- direction
- display
- dominant-baseline
- fill
- fill-opacity
- fill-rule
- font-family
- font-size
- font-size-adjust
- font-stretch
- font-style
- font-variant
- font-weight
- letter-spacing
- marker-end
- marker-mid
- marker-start
- opacity
- paint-order
- pointer-events
- shape-rendering
- stop-color
- stop-opacity
- stroke
- stroke-dasharray
- stroke-dashoffset
- stroke-linecap
- stroke-linejoin
- stroke-miterlimit
- stroke-opacity
- stroke-width
- text-anchor
- text-decoration
- text-overflow
- text-rendering
- transform
- transform-origin
- unicode-bidi
- vector-effect
- visibility
- white-space
- word-spacing
- writing-mode
Cite this
"Default sanitizer configuration". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/HTML_Sanitizer_API/Default_sanitizer_configuration JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy