Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

556 LESSON 20: Working with Frames and Linked Windows


What Are Frames?


HTML5 enables you to embed a second document into an existing page using what’s
called an inline frame. Inline frames are like images or video players; they can be
included anywhere within a page. Over time, inline frames became more commonly used,
and frames created using framesets were made obsolete. HTML5 does not include sup-
port for frames created using framesets, leaving only inline frames.

Why Were Frames Removed from HTML5?


Frames were removed from the HTML specification for several reasons. The primary
reason that they were removed was because the <frameset> tag replaces the <body> tag.
This can cause problems with some assistive technology as they are built to expect a
body on any web page.
But there are other reasons why frames caused problems. Frames prevent customers from
correctly bookmarking web pages. You visit a frame site and then click some links, but
when you try to bookmark the internal pages, your bookmark records only the top-level
page. Some designers tried to solve this problem with JavaScript, but that simply added
to the complexity of the pages and made them even more difficult for screen readers to
use.
Printing pages in frames is also difficult. Although most browsers will print the first page
or screen, they struggle with getting all the content. Plus, if the frameset doesn’t fit on the
page, it can result in some strange use of paper.
Linking to frames from external sites can be difficult. Often you have the choice of link-
ing to the front page or to an internal framed page that is missing navigation and other
elements contained in the frameset. This means that a framed page that is referenced in
search engine results could end up being displayed with no navigation or any site refer-
ences. This is not a good user experience, and most designers want their site logo and
navigation to appear on every page.

What About Iframes?


Iframes are different from frames because they are simply embedded into the web page,
just like an image or other multimedia. Iframes add all the benefits of frames with none
of the drawbacks. You can embed content from other parts of your website or completely
different websites right inside your web pages.
HTML5 adds a few new features to the <iframe> tag to add security and flexibility to
your frames. I will discuss those features later in this lesson.
Free download pdf