Providing alternate content
If the browser determines that it cannot render the
specified object, it then proceeds to render the content of the
object
element. In the example from
earlier in this section, should the browser not have the capacity to
render the GIF, it will display the alternative content (“A color
photograph of a daffodil”) instead.
<object data="daffodil.gif" type="image/gif" width="150" height="125">
A color photograph of a daffodil.
</object>
The alternative content may also be another object
element. Authors may provide several
layers of alternate content by nesting objects with different
implementations. The user agent will keep looking inside each object
element until it finds an object that
it can render.
In this example, borrowed from the HTML 4.01 Recommendation, a
Python applet is embedded on the page with the object
element. If the browser can’t render
the applet, an MPEG video is provided as a backup. If the video cannot
be rendered, there is a static GIF image, and finally, a text
description is provided if all else fails.
<object title="The Earth as seen from space" classid="http://www.observer. mars/TheEarth.py"> <object data="TheEarth.mpeg" type="application/mpeg"> <object data="TheEarth.gif" type="image/gif"> The Earth as seen from space. </object> </object> </object>
Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.