Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App
Next Article:
HTML <iframe> scrolling Attribute
Next article icon

HTML | <iframe> sandbox Attribute

Last Updated : 06 May, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The HTML <iframe> tag’s sandbox attribute restricts the behavior of the embedded content for added security. It allows or disallows specific capabilities such as form submission and scripting within the iframe.

When the sandbox attribute exists, it will: 

  • treat the content as being from a singular origin
  • It blocks form submission
  • It blocks script execution
  • It disables APIs
  • It also prevents links from targeting other browsing contexts
  • It stops the content from navigating its top-level browsing context
  • block automatically triggered features (such as automatically playing a video or automatically focusing a form control)

The value of the sandbox attribute will either be simply sandboxed (then all restrictions are applied) or a space-separated list of pre-defined values that will take away the actual restrictions.

Syntax:  

<iframe sandbox="value">

Attribute Values :

AttributeDescription
no-valuesApplies all restrictions, effectively disabling most capabilities of the embedded content.
allow-formsRe-enables form submission within the iframe.
allow-pointer-lockRe-enables pointer lock APIs within the iframe.
allow-popupsRe-enables popups within the iframe.
allow-same-originAllows the content of the iframe to be treated as being from the same origin as the parent page.
allow-scriptsRe-enables scripts within the iframe.
allow-top-navigationAllows the content of the iframe to navigate its top-level browsing context.

Example: In this example we displays GeeksforGeeks heading, iframe with sandbox attribute, and source set to GeeksforGeeks IDE. Basic structure without sandbox attribute values.

index.html
<!DOCTYPE html> <html>     <head>         <title>             HTML Iframe sandbox Attribute         </title>     </head>     <body>         <h1>GeeksforGeeks</h1>          <h2>HTML IFrame sandbox Attribute</h2>         <br />         <br />         <iframe             id="GFGFrame"             src="https://geeksforgeeks.org/community"             width="400"             height="200"             sandbox         >         </iframe>     </body> </html> 


Note: The HTML iframe syntax is correct, the https://geeksforgeeks.org website does not allow itself to be embedded in iframes on other domains. This is due to protective headers (X-Frame-Options, CSP) that prevent clickjacking and preserve content security. As a result, the iframe appears broken, even though the code itself is valid. You can check other website link to check the output.


Supported Browsers:The browsers supported by HTML IFrame sandbox Attribute are listed below 

  • Google Chrome
  • Edge 
  • Firefox
  • Opera
  • Safari

Next Article
HTML <iframe> scrolling Attribute

S

shubham_singh
Improve
Article Tags :
  • HTML
  • Web Technologies
  • HTML-Attributes

Similar Reads

  • HTML <iframe> align Attribute
    The HTML <iframe> align attribute is used to specify the alignment of the inline-frame according to the alternate element. Syntax <iframe align="left|right|middle|top|bottom">Attribute Values left: It sets the alignment of an iframe to left.right: It sets the alignment of an iframe to ri
    1 min read
  • HTML | <Iframe> frameborder Attribute
    The HTML Iframe frameborder Attribute is used to specify whether or not to display the border around the content of an <Iframe> Element. Syntax: <iframe frameborder="1 | 0"> Attribute Values: 0: It has a Default value. It sets the border on one state. 1: It sets the border on-off state.
    1 min read
  • HTML | <iframe> height Attribute
    The HTML <iframe> height attribute is used to specify the height of the <iframe> in terms of pixels. Syntax: <iframe height="pixels"> Attribute Values: It contains single value pixel which specifies the height of the iframes in terms of pixels. Below example illustrates the use of
    1 min read
  • HTML <iframe> longdesc Attribute
    The HTML <iframe> element's longdesc attribute provides a URL that links to a detailed description of the iframe's content, mainly for accessibility purposes. However, this attribute is deprecated in HTML5, with ARIA attributes and other techniques recommended for describing content. Syntax
    2 min read
  • HTML <iframe> marginheight Attribute
    The HTML <iframe> marginheight attribute specifies the vertical margin space, in pixels, between the iframe's content and its top and bottom borders. Syntax<iframe marginheight="pixels">Attribute Valuespixels: It contains the value i.e. pixel which specifies the top and bottom margin of
    2 min read
  • HTML <iframe> marginwidth Attribute
    The HTML <iframe> marginwidth attribute defines the horizontal margin space, in pixels, between the iframe's content and its left and right borders. Syntax<iframe marginwidth="pixels">Attribute Values: pixels: It contains the value i.e. pixel which specifies the right and left margin of
    2 min read
  • HTML | <iframe> name Attribute
    The HTML iframe name Attribute is used to specify a reference for an <Iframe> Element. The name attribute is also used as a reference to the elements in a Javascript. Syntax: <iframe name="name">Attribute Values: name: It specify the name for the Iframe element.UsageThe name attribute as
    1 min read
  • HTML <iframe> referrerpolicy Attribute
    The HTML <iframe> referrerpolicy attribute is used to specify the reference information that will be sent when fetching the result. Syntax <iframe referrerpolicy="value">Attribute Values: no-referrer: It specifies that no reference information will be sent along with a request.no-referre
    2 min read
  • HTML | <iframe> sandbox Attribute
    The HTML <iframe> tag's sandbox attribute restricts the behavior of the embedded content for added security. It allows or disallows specific capabilities such as form submission and scripting within the iframe. When the sandbox attribute exists, it will: treat the content as being from a singu
    2 min read
  • HTML <iframe> scrolling Attribute
    The HTML <iframe> scrolling Attribute is used to specify whether the scrollbar will be displayed or not in the <Iframe> Element. Basically, the scrollbar is used when the content is larger than the Iframe Element.  Note: This attribute has been DEPRECATED and is no longer recommended. Sy
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences