View Full Version : Replace IMG tag With Object Tag

01-17-2006, 05:35 PM
I read in a book somewhere that you should replace the IMG tag in XHTML with the OBJECT tag. Does anyone know how to do this? What PARAMs would be necessary to replace all the elements in the IMG tag? Doesn't sound to me that you could use this to make image links.

01-17-2006, 05:42 PM
The img tag is in the XHTML standard.

You need the alt and the src tags to make it complete and also you need to close the tag.

01-18-2006, 11:05 PM
Ooh goody. Another author writing about something they know nothing about. Hmm.

Thanks for the help.

Bill Posters
01-19-2006, 09:43 AM
The object element formally replaces a number of existing elements in XHTML 2.0, amongst them the img element, but it's still some way off of becoming a common reality.
Given the rate at which things really change in the web development industry, it'll be safe to use the img element for the next few years at least.
Even when support for using the object element to bring in imagery becomes broad, it's likely that most UAs will still support the use of img elements, so not something you need to worry about for the immediately foreseeable future.
Of course, much of which element you use will come down to which markup scheme you use - e.g. if you use XHTML 1.0 or even 1.1, then you're still pretty much free to stick with using img elements to add content images to your pages.
Beyond that, the object element will purportedly be the element to use for that particular job.

Additional reading…

01-21-2006, 07:18 PM
Here it is I found it. You can use the title attribute to replace the alt attribute. But I see no way to make image links. I know this isn't the standard but it works nevertheless.

Yes I use XHTML 1.0 transitional. So I'll stick to the image tag. But I was still curious about it anyway.

<object data="tiger.gif" type="image/gif" width="242" height="242"></object>

<object data="tiger.jpg" type="image/jpeg" width="242" height="242"></object>

<object data="tiger.png" type="image/png" width="242" height="242"></object>

<object data="tiger.svg" type="image/svg" width="242" height="242"></object>

You can nest these to.

<object data="tiger.gif" type="image/gif" width="242" height="242">
<object data="tiger.jpg" type="image/jpeg" width="242" height="242">
<object data="tiger.png" type="image/png" width="242" height="242">
<object data="tiger.svg" type="image/svg" width="242" height="242">
Put text etc in here.

01-21-2006, 07:36 PM
Bit stupid if you ask me!

Sure, the SVG is better as an object, but why use object tags instead of image tags, when image tags are meant for ...displaying images!?

Bill Posters
01-23-2006, 12:29 PM
Bit stupid if you ask me!

…why use object tags instead of image tags, when image tags are meant for ...displaying images!?

I think it's because of the nesting and degradation capabilites that come with using object elements.
Also, the plan is (supposedly) to separate out element (objects) which aren't strictly generated by the markup/xml such as img 'objects' and gather them into the more generic object element tag which will be able to support a number of different file formats, not just bitmap images.
From what I understand of it, it's all part of the gradual purification and distillation of markup/structural language.

Hmmm, all this talk of purification and distillation and it's not even noon. ;)

01-23-2006, 04:12 PM
Ah, so is this a plan for XHTML 2.0 ?

Bill Posters
01-23-2006, 06:05 PM
Pretty much (i.e. from what I understand ;) ).