What Is Frame In HTML With Example: Complete Guide

In the realm of web development, particularly HTML, you'll often encounter the term 'frame'. It's a primitive layout element that helps divide a web page into different sections. Frames enable you to display multiple HTML pages or sections of a single page within a single browser window.

What is an HTML iFrame? (Embedding Maps, Videos, & More) 🖼️
What is an HTML iFrame? (Embedding Maps, Videos, & More) 🖼️

Frames were initially introduced to break out of the traditional single-page layout and bring in more dynamic and complex designs. However, they fell out of favor due to accessibility, SEO, and maintenance issues, which led the W3C to phase out support for them.

Embedding Images in HTML using <img>
Embedding Images in HTML using <img>

Understanding HTML Frames

The <frame> and <iframe> tags were used to create frames. While browsers no longer support the former, the latter is still in use. Let's first understand the basic syntax of the now-deprecated <frameset> and <frame> tags, which might still be relevant for understanding modernelements.

an image of a web page with the text'day 17 iframe '
an image of a web page with the text'day 17 iframe '

The <frameset> tag defined the frame set, and it contained one or more <frame> tags to define individual frames. Here's a simple example:

```html ```

rows and cols Attributes

an info sheet with the text basic html structure in blue and white, on top of it
an info sheet with the text basic html structure in blue and white, on top of it

The rows and cols attributes split the browser window into sections, where frame sources are embedded. In the example above, the screen is divided into two sections, each holding a frame with sources top.html and bottom.html respectively.

You could also use numbers to specify the size of each frame, like so:

```html ```

Frame Borders and Scrolling

a page structure in html with the text's title below it and an image of a
a page structure in html with the text's title below it and an image of a

The border attribute controlled the thickness of the border between frames. You could set it to 0 to remove the border. The scrolling attribute controlled scrolling in each frame. If set to yes, it enabled scrollbars in the frame.

For instance, frameset cols="100,50%" border="0"> frames the window into two equal parts with no border between them.

HTML iframe: A Modern Alternative

Inserting and styling images in HTML 5.
Inserting and styling images in HTML 5.

iframe (Inline Frame) is a modern alternative to outdated frames. It integrates an external document within a HTML document, treating it as an independent HTML page.

Iframes are widely used for a variety of purposes, like integrating content from external sources, displaying map services (like Google Maps), or embedding videos (like YouTube videos). They're SEO-friendly and don't have the accessibility issues of frames.

an image of a web page with the words'body'and'reader '
an image of a web page with the words'body'and'reader '
an image of a computer screen with the words inline frame in it's bottom corner
an image of a computer screen with the words inline frame in it's bottom corner
the structure of a web page
the structure of a web page
an image of a computer screen with the names of different types of web pages on it
an image of a computer screen with the names of different types of web pages on it
Very Simple HTML CSS Image Gallery
Very Simple HTML CSS Image Gallery
Learn HTML Basics: Introduction to HTML Structure & Elements
Learn HTML Basics: Introduction to HTML Structure & Elements
Learn HTML #html #aitechworlds #aitechworldsinsta
Learn HTML #html #aitechworlds #aitechworldsinsta
the page structure in html5
the page structure in html5
🧾 How to Create Tables in HTML
🧾 How to Create Tables in HTML
#html #webdevelopment #frontend #programming #coding #javascript #webdesign #learntocode #developers #techsuggester | Tech Suggester
#html #webdevelopment #frontend #programming #coding #javascript #webdesign #learntocode #developers #techsuggester | Tech Suggester
an image of a computer screen with the words body and name
an image of a computer screen with the words body and name
an image of a computer screen with the words canvass in html and csss
an image of a computer screen with the words canvass in html and csss
About HTML tags
About HTML tags
Basic HTML Structure
Basic HTML Structure
an image of a web page with the text structure in red and white on it
an image of a web page with the text structure in red and white on it
Wireframe Design 101: 6 Steps to Create a Wireframe | Adobe XD Ideas
Wireframe Design 101: 6 Steps to Create a Wireframe | Adobe XD Ideas
Design Elements in HTML & CSS
Design Elements in HTML & CSS
an image of a diagram with words in the middle and below it that are labeled
an image of a diagram with words in the middle and below it that are labeled
🔥 Semantic HTML Cheat Sheet for Frontend Developers
🔥 Semantic HTML Cheat Sheet for Frontend Developers
HTML Page Structure
HTML Page Structure

Basic iframe Syntax

The basic syntax for an iframe is as follows:

```html ```

The src attribute specifies the URL of the page to embed. The width and height attributes set the size of the iframe.

For example, an iframe embedding a YouTube video might look like this:

```html ```

iframe Sandbox Attribute

To enhance security, you can use the sandbox attribute to apply additional restrictions to the content of the iframe. For instance, setting sandbox="allow-same-origin allow-scripts allow-forms" allows scripts and forms to run, but prevents other top-level browsing context features.

This brief overview should have provided a solid understanding of HTML frames, despite their obsolescence, and iframe, their modern equivalent. Understanding these elements is crucial for web developers, even if they're not used as frequently as they once were. Happy coding!

Related Articles

Tutorialspoint Typescript Pdf Free Download Hyperlink Html In Text Www Tutorialspoint Com Jsp Explain Table In Html With Example Html Dom Definition Html Tutorialspoint Full Pdf Web Dev Simplified Html Css Html To Zip Html Tutorial For Absolute Beginners Html To Zim