loading

HTML Iframes

Html Iframe, Inline Frame, Iframe Syntax, Iframe Title, Iframe Height And Width, Iframe Border, Iframe Target

An HTML iframe is used to display a web page within a web page.


HTML Iframe Syntax

An inline frame is specified by the HTML <iframe> tag.

To embed a different document inside the current HTML document, use an inline frame.

Syntax

				
					<iframe loading="lazy" src="about:blank" title="description" data-rocket-lazyload="fitvidscompatible" data-lazy-src="http://url"></iframe><noscript><iframe src="url" title="description"></iframe></noscript>
				
			

Advice: It’s best to make sure the <iframe> has a title attribute at all times. Screen readers utilize this to read out the contents of the iframe.

Iframe - Set Height and Width

The size of the iframe can be specified using the width and height properties.

By default, the height and width are given in pixels:

Example

				
					<iframe loading="lazy" src="about:blank" height="200" width="300" title="Iframe Example" data-rocket-lazyload="fitvidscompatible" data-lazy-src="http://demo_iframe.htm"></iframe><noscript><iframe src="demo_iframe.htm" height="200" width="300" title="Iframe Example"></iframe></noscript>
				
			

Or you can add the style attribute and use the CSS height and width properties:

Example

				
					<iframe loading="lazy" src="about:blank" style="height:200px;width:300px;" title="Iframe Example" data-rocket-lazyload="fitvidscompatible" data-lazy-src="http://demo_iframe.htm"></iframe><noscript><iframe src="demo_iframe.htm" style="height:200px;width:300px;" title="Iframe Example"></iframe></noscript>
				
			

Iframe - Remove the Border

An iframe has a border surrounding it by default.

Use the CSS border property and the style attribute to remove the border:

Example

				
					<iframe loading="lazy" src="about:blank" style="border:none;" title="Iframe Example" data-rocket-lazyload="fitvidscompatible" data-lazy-src="http://demo_iframe.htm"></iframe><noscript><iframe src="demo_iframe.htm" style="border:none;" title="Iframe Example"></iframe></noscript>
				
			

With CSS, you can also change the size, style and color of the iframe’s border:

Example

				
					<iframe loading="lazy" src="about:blank" style="border:2px solid red;" title="Iframe Example" data-rocket-lazyload="fitvidscompatible" data-lazy-src="http://demo_iframe.htm"></iframe><noscript><iframe src="demo_iframe.htm" style="border:2px solid red;" title="Iframe Example"></iframe></noscript>
				
			

Iframe - Target for a Link

A link can have an iframe as its target frame.

The iframe’s name attribute must be referred to by the link’s target attribute:

Example

				
					<iframe loading="lazy" src="about:blank" name="iframe_a" title="Iframe Example" data-rocket-lazyload="fitvidscompatible" data-lazy-src="http://demo_iframe.htm"></iframe><noscript><iframe src="demo_iframe.htm" name="iframe_a" title="Iframe Example"></iframe></noscript>
<p><a href="https://www.codingask.com" target="iframe_a">Codingask.com</a></p>

				
			

Chapter Summary

  • The HTML <iframe> tag specifies an inline frame
  • The src attribute defines the URL of the page to embed
  • Always include a title attribute (for screen readers)
  • The height and width attributes specify the size of the iframe
  • Use border:none; to remove the border around the iframe

HTML Script Tags

Tag Description
<iframe> Defines an inline frame

html iframe

inline frame

iframe syntax

iframe title

iframe height and width

iframe border

iframe target

HTML

HTML5

HTML tutorials

Learn HTML

Free HTML tutorials
HTML Example
HTML Explained

HTML iFrames: Embedding Content with Ease

When it comes to embedding content from external sources into your web pages, the HTML “ element is a powerful tool. An iFrame, short for “inline frame,” allows you to seamlessly incorporate content from other websites or web applications directly into your own HTML document.

The basic syntax for an iFrame is as follows:

“`html

“`

The `src` attribute specifies the URL of the content you want to embed, while the `title` attribute provides a descriptive label for the iFrame, which is important for accessibility.

You can also customize the size and appearance of the iFrame using additional attributes:

– `width` and `height`: Specify the dimensions of the iFrame in pixels or percentages.

– `frameborder`: Set to “0” to remove the default border around the iFrame.

– `scrolling`: Determine whether scrollbars should be displayed (e.g., “yes”, “no”, “auto”).

– `allowfullscreen`: Allow the embedded content to be displayed in full-screen mode.

By leveraging iFrames, you can seamlessly integrate content from various sources, such as maps, videos, or even entire web applications, into your web pages. This can enhance the user experience and provide a more cohesive and engaging presentation of information.

Remember to use iFrames responsibly and consider potential security implications, as the embedded content may come from external sources beyond your control.

HTML iFrames: Embedding Content with Ease

In the world of web development, the HTML iframe element plays a crucial role in seamlessly embedding content from external sources onto a web page. An inline frame, or iframe, allows you to incorporate content from a separate URL into your own HTML document, creating a nested browsing context.

The syntax for implementing an iframe is straightforward:

The `src` attribute specifies the URL of the content you want to embed, while the `title` attribute provides a descriptive label for the iframe, enhancing accessibility.

You can also customize the size and appearance of the iframe using additional attributes:

– `width` and `height`: Specify the dimensions of the iframe in pixels or percentages.

– `frameborder`: Set the width of the iframe’s border, with 0 indicating no border.

– `target`: Determine how the embedded content should be displayed, such as in a new window or tab.

By mastering the use of iframes, web developers can effortlessly incorporate external content, such as maps, videos, or even entire web applications, into their web pages, creating a seamless and integrated user experience.

Share this Doc

HTML Iframes

Or copy link

Explore Topic