Object element Example: How to use the mime type

This example is part of the article Add Multimedia to your Web documents, part 2.

We can decide to send a raw text file, with text/plain, to avoid to have to cut and paste the source code of your program or html web page in a pre and write things like that which are difficult to update:


<h4>An html head example</h4>
<pre>
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html 
   xmlns="http://www.w3.org/1999/xhtml" 
   xml:lang="en" lang="en"&gt;
&lt;head&gt;
	&lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
	&lt;title&gt;Your Title&lt;/title&gt;
&lt;/head&gt;


</pre>

Example: inserting some python code

<object 
   data="http://example.org/source/wiki2xhtml.py" 
   type="text/plain">
   <p>Source code of  
   <a href="/source/wiki2xhtml.py">wiki2xhtml</a></p>
</object>

Another example: presenting HTML source code

<object 
   data="http://example.org/source/example.html" 
   type="text/plain">
   <p>Source code of the 
   <a href="/source/example.html">HTML file</a></p>
</object>

Something to be careful of: the MIME-type sent by the server has precedence over the MIME-type given in the object element. If you don't have access to the configuration of your Web server, you could use a copy of your HTML file with a .txt extension, such as example.html.txt. Usually webservers are configured to send .txt files as text/plain; otherwise you can locally configure it to be sent as text/plain. For example, you can achieve this with a .htaccess file in Apache.