HTML Attributes

HTML sandbox attribute

Applies restrictions to an iframe. An empty attribute applies the full sandbox; allow-* tokens selectively relax restrictions. Combining allow-scripts with allow-same-origin for same-origin content can undermine isolation. Applicable elements include: <iframe>. Check each element’s value rules.

Formal Syntax & Structure

html syntaxhtml
sandbox

Parameters & Attributes

NameTypeDescription
sandboxspace-separated permission tokensApplies restrictions to an iframe. An empty attribute applies the full sandbox; allow-* tokens selectively relax restrictions. Combining allow-scripts with allow-same-origin for same-origin content can undermine isolation.

Working Example

Example Snippethtml
<iframe title="Untrusted preview" sandbox srcdoc="&lt;p&gt;Preview&lt;/p&gt;"></iframe>

Browser Compatibility

Minimum supported versions across modern rendering engines

Chrome
5
Yes
Edge
12
Yes
Firefox
17
Yes
Safari
5
Yes
Checked desktop BCD snapshot: iframe sandbox base attribute; tokens differ. Versions denote the recorded start of support (≤ means at least that early), not a guarantee of all behavior. Unresolved mirror and preview rows omitted.
HTML Living Standard
HTML Reference