1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Strict XHTML: IMG vs. OBJECT elements

Discussion in 'Web Design & Development' started by cristobal03, Apr 4, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. cristobal03

    cristobal03 Thread Starter

    Joined:
    Aug 5, 2005
    Messages:
    3,084
    Hi all, this is my first post in the WebDev forum (y)

    My boss resourced me to redesign our company website, and it's been forever since I authored a site so I'm catching up on the latest specs. I spent the last few days reading the W3C specification for HTML 4.01 as well as the spec for XHTML 1.0.

    Now, my question is this: W3C says object elements like IMG, IFRAME, etc. may be going the way of the Dodo. However, scratching out a test index using IE 6 to browse seems to indicate iffy support of OBJECT as a replacement for IMG.

    Here's the code I tossed together:

    HTML:
    <body>
      <object data="./someimg.gif" type="image/gif">
        A random GIF image.
      </object>
    </body>
    
    That gives me a blank page. If I intentionally break the object tag (by using an incorrect MIME type, for example) the alternate content does display. Also, if I assign the element's height and width attributes, the image will display in a scrollable frame.

    What gives? Should I use IMGs instead? I'd prefer OBJECTs if it's possible.

    Thanks for any tips/feedback.

    chris.
     
  2. php guy

    php guy

    Joined:
    Dec 17, 2004
    Messages:
    601
    W3C says those objects may be going away in the future, but for now, I'd stick with the tag.

    The main reason for this is that older browsers reading your page with <object> for the image won't have a clue what to do with it, and since <img> is still supported by the current browsers, it's best to stick with the most compatable tag.
     
  3. namenotfound

    namenotfound

    Joined:
    Apr 30, 2005
    Messages:
    3,012
    Using <object> to embed images are fine in FF and O, but tend to cause problems in IE (as I tested this out 2 years ago).

    Stick with <img>

    Also I'm pretty sure W3C mentions that for XHTML 2.0 which still have a long time before it comes out.
    Where as, any element will be able to use "src" to embed images.

    <p src="image.jpg"> <span src="image.jpg"> etc.

    Supposely when XHTML 2.0 does come out, <object src="image.jpg"> will get better support in IE, but as it is right now using "data" <object data="image.jpg"> it isn't supported well in IE.
     
  4. cristobal03

    cristobal03 Thread Starter

    Joined:
    Aug 5, 2005
    Messages:
    3,084
    Thanks guys (y)

    chris.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/456027