HTML and CSS Reference
In-Depth Information
here! This concept of nesting alternative content within an element is particularly im-
portant to the elements to come later in this chapter, such as video , so keep it in mind.
Note Although object can theoretically be used to embed many types of media,
the reality is that many new elements added in HTML5, as well as existing elements,
have usurped object on several fronts. video and audio should be used in place
of object for embedding those types of media, and img has long been the ubiquitous
answer to embedded images, despite object 's attempt to supersede it. Also, iframe
(discussed in the next section) is a better alternative for nesting one web page inside
another. The applet element for Java applets, however, is obsolete in HTML5, and
for this type of content object should be used instead. It should also be used for plug-
in-based media such as Adobe Flash content.
Embedding HTML: iframe
Netscape Navigator 2.0 introduced the ability to create frames, which seemed pretty
innovative at the time. The ability to construct an HTML page out of numerous other
pages meant, for instance, that in a page that had a frame for content and a frame for a
navigation bar, the content of the page could be loaded without the need to reload the
navigation bar. Also, the contents of the page could be scrolled while leaving the navig-
ation bar stationary. Along with these advantages came a number of problems, however,
which led to frames falling out of favor. Among these were difficulties search engines
had navigating a frameset, leading to situations where a particular frame outside of its
frameset context might turn up in search results. Since the days of Netscape Navigator,
advances in web browser and web server technology have made frames obsolete (CSS,
for instance, can fix the position of content so it does not scroll). In HTML5 the frame
and frameset elements are obsolete and must not be used. What remains in HTML5 is
the iframe element, known as an inline frame . This element allows an entire HTML
page (or snippets of HTML code) to be embedded in another page. The ability to em-
bed one page into another is useful for incorporating third-party HTML code into your
own web page. For example, this element is often used to embed third-party ads (for in-
stance, Google's AdSense ads). Other uses include Facebook's “Like” button and Twit-
ter's “tweet” button, which are often seen embedded in blog posts or similar and are used
to share the article on those social networks.
An inline frame might also be used to embed more extensive third-party content on your
site, such as a news feed or articles from another website.
Search WWH ::




Custom Search