Home Snippets Projects Donate

Get Snippets For:

   Java    HTML/CSS JavaScript

Inline Frames (iframes)

Code Description:

Inline Frames, are created from the <iframe> tag. Inline Frames create a window to display an embedded website within your website. Iframes typically have a height and width attribute to specify the size of the frame along with a source (src) attribute to determine the website to display. This is very helpful for displaying a YouTube video withing your website. If the YouTube video is able to be embedded, you can click the share button on the video and then click the Embed option to generate the iframe code for you.

Inline Frame Syntax:

<iframe src="https://www.freecode.net" width="300" height="300"></iframe>

Runnable Iframe Example Code (YouTube Video):

<!DOCTYPE html>
<html>
    <head>
        <title>YouTube Iframe Example</title>
	   
    </head>
 
    <body>
        <iframe width="560" height="315" src="https://www.youtube.com/embed/C0DPdy98e4c" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
    </body>
</html>

How to Run This Code:

Simply paste this code into a plain text file with the ".html" extension and save it. You will then be able to open it in the web browser of your choice.

Output:

Related Links: