HTML Iframe

iframes in HTML

Web pages can be embedded within other websites using an HTML Iframe (a webpage within a webpage). An inline frame is a type of frame that is defined by the HTML iframe> tag.

In an HTML document, an iframe creates a rectangular area in which another page can be displayed.

JavaScript allows the content of the webpage and the content of the iframe to communicate with one another.

Syntax for iframes

The <iframe> tag in HTML describes an in-frame environment.

    <iframe src=\”URL\”></iframe>

The \”src\” element in this case identifies the full Uniform Resource Locator (URL) of the inline frame.
Alter the iframe\’s width and height to suit your needs.

The \”width\” and \”height\” parameters of an iframe allow you to modify the frame\’s dimensions. The properties\’ values are supplied in pixels by default, however you can also change this to a percentage if you like. i.e. 50%, 60% etc.

Pixels Example:

<!DOCTYPE html>
<html>
<body>
<h2>HTML Iframe example</h2>
<p>Size the iframe using the height and width parameters.</p>
<iframe src=\”https://www.coderazaa.com/\” height=\”500\” width=\”400\”></iframe>
</body>
</html>

Percentage Example:

<!DOCTYPE html>
<html>
<body>
<h2>HTML Iframe example</h2>
<p>Size the iframe using the height and width parameters.</p>
<iframe src=\”https://www.coderazaa.com/\” height=\”80%\” width=\”50%\”></iframe>
</body>
</html>

 

The iframe\’s width and height can also be modified with CSS.

Example:

<!DOCTYPE html>
<html>
<body>
<h2>HTML Iframe example</h2>
<p>Size the iframe using the height and width parameters in CSS.</p>
<iframe src=\”https://www.coderazaa.com/\” style=\”width:800px;height:400px;\” ></iframe>
</body>
</html>

 

Remove the border of iframe

There is typically a border around an iframe by default. Applying the style> attribute and the border property of CSS will get rid of the border.

Example:

<!DOCTYPE html>
<html>
<body>
<h2>HTML Iframe example</h2>
<p>Remove  iframe border using  CSS.</p>
<iframe src=\”https://www.coderazaa.com/\” style=\”border:none\” ></iframe>
</body>
</html>

Referral Link\’s Iframe Target

By utilising iframe, you may choose which frame a link will open in. The iframe\’s name attribute must be referenced in the link\’s target attribute.

Example:

<!DOCTYPE html>
<html>
<body>

<h2>Iframe Target for a Link Example</h2>
<iframe height=\”400px\” width=\”100%\” src=\”contact.php\” name=\”iframe_a\”></iframe>
<p><a href=\”https://www.coderazaa.com/html\” target=\”iframe_a\”>Coderazaa.com</a></p>
<p>If the name of the iframe and the link target are not the same, the link will not open as a frame.</p>

</body>
</html>

Insert a video from YouTube using iframe

The iframe> tag allows you to embed a video from YouTube directly onto your site. Your website will automatically play the uploaded video, and you can customise its dimensions, playback speed, and more.

These are some ways for embedding a YouTube video on a website:

  1. Choose the video from YouTube that you wish to embed.
  2. To share this movie, select the SHARE button.
  3. Choose the Embed > button.
  4. Get the HTML source.
  5. Add this code to your HTML document.
  6. Modify the dimensions to your liking (as per requirement).

Example

\"example

Related Posts
Introduction to HTML

HTML Introduction HTML is the most common language used to mark up Web pages. What does HTML mean? Hyper Text Read more

What is HTML

HTML stands for Hyper Text Markup Language, which is a programming language used to make web pages and web apps. Read more

HTML Basic Examples

In this chapter, we\'ll show you some simple examples of HTML code. Don\'t worry if we use tags that you Read more

HTML text Editors

Editors for HTML text HTML files are text files, so any text editor can be used to make them. Text Read more

HTML Tags

Learn HTML Tags HTML tags are kind of like keywords that tell a web browser how to format and show Read more

HTML Elements

Elements make up an HTML file. These elements are what make web pages and tell you what content is on Read more

HTML Attributes

Attribute in HTML Attributes in HTML are special words that tell you more about an element. Attributes change the way Read more

HTML Headings

Headings in HTML The <h1> to <h6> tags are used to set up headings in HTML. <h1> shows which heading Read more

Scroll to Top