Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Objects Includes and iframes

Harry Tran
Harry Tran
10,618 Points

What are iFrames used for?

I use to understand that iFrame would be able to pretty much hotlink another site, but for professional site building what's the use of creating an iframe element?

1 Answer

Hugo Paz
Hugo Paz
15,622 Points

The HTML <iframe> tag is used to specify an inline frame, or, as the HTML5 specification refers to it, a nested browsing context.

An inline frame allows you to embed another document within the current HTML document. It also allows you to provide an inline frame without using another document - by simply passing the content to the <iframe> via the srcdoc attribute.

Inline frames are often used in online advertising, where the contents of the <iframe> is an ad from an external party.

Inline frames are typically created using a second HTML document. This second document contains the content within the inline frame. You use the iframe src attribute to specify the source of the other document, as well as other attributes to determine the height, width etc.

Harry Tran
Harry Tran
10,618 Points

Thank you Hugo, that seems to make sense to me why they're useful.