1. Technology

sandbox - HTML Attribute for Iframes

By

Sandbox Attribute Description:

The sandbox attribute defines the restrictions on the content of the IFRAME element.

This attribute is valid in HTML5.

The Sandbox Attribute is Used with These Tags:

The Sandbox Attribute Contains:

The sandbox attribute defines the extra restrictions on the IFRAME. There are four values you can apply, separating multiple values with spaces:

  • allow-forms—allow form submission
  • allow-same-origin—allow scripts to access content like cookies from the same origin domain
  • allow-scripts—allow scripts to run in this IFRAME
  • allow-top-navigation—allow the IFRAME links and scripts to the _top target

Here is an example of an IFRAME with a sandbox attribute.

<iframe sandbox>
Your browser does not support iframes.
</iframe>

And one where forms are allowed to be submitted from the IFRAME:

<iframe sandbox="allow-forms">
Your browser does not support iframes.
</iframe>

Sandbox Default Value:

The sandbox attribute has no default value. If the sandbox attribute is present with none of the above keywords in place, then all restrictions are in place on the IFRAME.

Sandbox is Valid in HTML Versions:

  • HTMl5
  • XHTML5

Sandbox Attribute DTD:

HTML5

<doctype html>

©2014 About.com. All rights reserved.