DotNet-100-PreWork-GitBook
  • DotNet PreWork
  • Part 0: Intro
    • 1.0: Installation
    • 2.0: Getting Started
    • 3.0: Configuration
  • Part 1: HTML Fundamentals
    • Basic Tags
    • H & P Tags
    • Lists
    • Links
    • Images
    • Tables
    • Divs
    • Inputs
    • Forms
    • Sections
    • Articles & Headers
    • Footers
    • Navs
    • iFrames
  • Part 2: CSS Fundamentals
    • CSS Set Up
    • Classes
    • Ids
    • Margins & Padding
    • Fonts
    • Backgrounds
    • Widths & Heights
    • Borders
    • Positions
  • Part 3: C# Fundamentals
    • 1.0: Hello World
    • 2.0: Variables
    • 3.0: Basic Types
    • 3.0a: Types Challenges
    • 3.0b: Types Challenges Answers
    • 4.0: Operators
    • 5.0: Strings
    • 6.0: Booleans
      • 6.0a: Boolean Challenge
      • 6.0b: Challenge Answers
    • 7.0: Conditionals
      • 7.1: Switch Case
      • 7.2: If Statements
      • 7.3: Ternary Expressions
    • 8.0: Numbers
    • 9.0: Loops
      • 9.0a: Loop Challenges
      • 9.0b: Challenge Answers
    • 10.0: Classes and Objects
    • 11.0: Properties
    • 12.0: Useful-Links
Powered by GitBook
On this page
  • File Location
  • Description
  • Sample Code
  • Discussion
  • Challenge
  • Extra Reading
  1. Part 1: HTML Fundamentals

iFrames

In this module we wil learn about the <iframe> tag.

File Location

For this module, you should be working in the following location:

    DotNetProjects
        └── HTMLCSSPreWork
            └── 1-HTML-Basics

                14-iframe.html <---You should be here.

            └── 2-CSS-Basics
            └── 3-assets

Description

The inline frame (iframe) is used to embed another document inside of an HTML document. This is a fairly straight-forward way to describe the <iframe>, and that is because it is a fairly straight-forward element to use in practice. Embedding third-party media is a common use of <iframe> and we'll show you how to insert a YouTube video into your own HTML using this tag.

Sample Code

Add the following sample code to your file:

<!DOCTYPE html>
<html>
<head>
    <title>iframe</title>
</head>
<body>

    <iframe width="560" height="315" src="https://www.youtube.com/embed/owsfdh4gxyc" frameborder="0" allowfullscreen></iframe>       

</body>
</html>

Discussion

It may seem strange that this isn't a void element, similar to the <img /> tag, but that is explained readily enough: compatibility with legacy versions of web browsers. If you've already tried to insert text between the opening/closing tags, you probably noticed that the text doesn't appear when the document is rendered. This is because the browser simply ignores that content. <iframe> can still be styled, as we have done above with the width and height attributes. However, you'll want to consider how your styling may be rendered on a variety of devices.

Challenge

Try changing the src attribute to a different target. How does that affect your layout? Practice changing the width and height using values such as percentages (i.e. width="20%").

Extra Reading

PreviousNavsNextPart 2: CSS Fundamentals

Last updated 6 years ago

Resources:

http://html.com/tags/iframe/