What are the differences between Div and IFrame?

Goliathstwin

Member
Joined
Mar 21, 2015
Messages
30
Points
8
My HTML skills are being improved day by day by I am learning it recent weeks, just a thing making me stuck is distinguish the differences between Div and IFrame when using it in html file? when should I use Div and IFrame? Can any one explain me?
 

EnricTellez

New member
Joined
Dec 19, 2016
Messages
27
Points
0
a div is just a block which you can fill with stuff like p tags or images.
an iframe is something thats loaded on a different server but displays on your page.

like for example you want to show a google maps thing on your page, you use an iframe so you get the information from googles server.
iframes are really cool, you will likelly use them a lot. :)
 
Last edited:

Mike001

New member
Joined
Apr 27, 2016
Messages
578
Points
0
Let me give you a developers explanation of the difference between a DIV and an iFrame.

When we place a DIV (division) in an HTML document it is meant to be used as a container for HTML elements. A DIV resides in the same window as the body element. It is normally used to separate content for placement and styling. It is not unusual to have div elements nested inside other div elements to allow for very specific styling and browser window placement. Div elements are block level elements in HTML.

An iFrame is meant to load information into your browser window from another sites pages. For instance incorporating a Google Map into the browser window of your site would normally be placed in an iFrame. An iFrame will act as a child element to the main page it resides on. iFrames are inline elements in HTML.

I hope this helps explain the difference between the two elements.
 

dominictuan

New member
Joined
Feb 3, 2021
Messages
2
Points
1
A div and an iframe no matter what the position type of the div is not equivalent. An iframe has an src attribute that lets it load external or other internal HTML pages within your current page. You cannot do this with a div by itself.

There are ways around this, however, it sounds like your just showing a modal popup. In which case you should use a div. Unless you have a need to load external HTML an iframe is not the answer.
 

pngtojpg

New member
Joined
Aug 22, 2022
Messages
3
Points
1
with iframe you can embed websites or html pages
with div you can use only codes
 

amysimmons

New member
Joined
Aug 6, 2022
Messages
16
Points
3
<div> and <iframe> are both HTML elements, but they are used for different purposes.
A <div> element is a container for HTML elements, which can be used to group elements together and apply styles to them. A <div> is a block-level element, which means that it takes up the full width of its parent container and creates a new line after it. It can be used to create a layout structure for a webpage.
An <iframe> element, on the other hand, is used to embed another HTML document within the current document. It is used to embed external content, such as a video, a map, or another webpage, within the current webpage. An <iframe> is an inline element, which means that it only takes up as much width as its content needs and does not create a new line after it.
In summary, a <div> is used for layout and structure, while an <iframe> is used to embed external content.
 

Emma0512

New member
Joined
Jan 23, 2023
Messages
1
Points
1
A div is a container element in HTML that is used to group other HTML elements together, while an iframe is an HTML element that allows you to embed another HTML document within the current HTML document.

One key difference between the two is that a div does not have its own separate document, while an iframe does. This means that elements within an iframe are not directly affected by the styles and layout of the parent document, while elements within a div are. Additionally, an iframe can be used to load content from a different website, while a div can only contain content within the same website.

Another key difference is that iframes can be used to embed another website inside a webpage and can also be used to embed videos, PDFs, maps, etc. DIVs are used to group elements and apply CSS styles to them.

Finally, iframes have a performance impact on the site as they load content from another website which might have different performance characteristics.
 
Older threads
Replies
5
Views
16,035
Replies
9
Views
9,108
Replies
27
Views
18,856
Replies
14
Views
10,629
Newer threads
Replies
8
Views
7,292
Replies
1
Views
5,684
Replies
12
Views
8,384
Replies
7
Views
6,187

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top