The <object> element

In XHTML Strict the only way to include content other than images is to use the <object> element. As an alternative you can provide a link to a file using the standard <a> element, but this opens up the content on a new page (or even worse in another application).

Basic syntax

<object type="mime/type" data="source.file"
        width="450" height="150">
 put alternative content here in case 
 browser can't display it
</object>

The type attribute refers to the actual MIME type of the content and the data attribute is the URL to the actual content. Some examples are:

text/plain
Plain text files
text/xml
XML data files
image/gif
GIF image

There are scores of MIME types and each identifies a particular type of document.

For example:

<object type="text/plain" data="readme.txt"
        width="450" height="50">
 <a href="readme.txt">Read me!</a>
</object>

Results in:

For a browser which cannot display the object you would see the alternative; in this case:

Checkout the examples of different objects using the basic syntax. Note: you may get variable results, depending on your browser. For example, Internet Explorer 7 does not like the 'image/jpg' MIME type.

The basic syntax works for a range of content, but in most not trivial cases you will want to use some of the more advanced features.

Valid XHTML 1.0! | Valid CSS! | WCAG Approved AA
Page design by: John P Scott - Hosting with: Netcetera