snowboard01 Posted June 7, 2006 Share Posted June 7, 2006 Hi this is a nooby question. Well I'm a nooby person. So here it is. What is the better tag to use to show an image on a webpage?object: <object type="image/gif" data="http://mysite.myhost/myimage.gif" width="50px" height="50px"></object> Or img <img src="mysite.myhost/myimage.gif" /> Is one better supported? Should I use image because it is designed for images? should I use object because the w3c may eliminate the img tag in favor of object? I an very confused. Please help me.Thank you. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 7, 2006 Share Posted June 7, 2006 Use the <img> tag, I don't think it is going anywhere and to my understanding several older browsers do not support the object tag. Link to comment Share on other sites More sharing options...
snowboard01 Posted June 7, 2006 Author Share Posted June 7, 2006 Ok thanks I just wanted to know. In what case should I use the object tag? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 7, 2006 Share Posted June 7, 2006 Typically for multimedia I think, videos or Flash or something like that. Someone else might be able to give more examples.Also, a question for everyone, instead of doing this:<object ...></object>Is it still valid to do this:<object ... />I've always wondered that.. like if I have an empty textarea do I need an explicit closing tag. Link to comment Share on other sites More sharing options...
snowboard01 Posted June 8, 2006 Author Share Posted June 8, 2006 Does this <object /> or <object></object> apply to all elements? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 8, 2006 Share Posted June 8, 2006 That's my question, and if it is even valid to close the single tag if there is no inner content.Such as <div class="sweet_colored_bar" /> Link to comment Share on other sites More sharing options...
justsomeguy Posted June 8, 2006 Share Posted June 8, 2006 I guess I answered my own question. This validates: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html> <head><title>Test</title></head> <body> <div>Test test <div /> <p /> <object /> <textarea rows="1" cols="1" /> </div> </body></html> Oddly enough though, this does not validate: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html> <head><title>Test</title></head> <body> Test test <div /> <p /> <object /> <textarea rows="1" cols="1" /> </body></html> You are not allowed to have plain text, a span, object, textarea, or things like that inside the root of the body. They need to be in a container like div, p, h1, etc. I didn't know that. Error Line 9 column 12: document type does not allow element "object" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "address", "fieldset", "ins", "del" start-tag.(mods: is it possible to get the html codeboxes to preserve indentation, or does the syntax coloring forbid that) Link to comment Share on other sites More sharing options...
snowboard01 Posted June 8, 2006 Author Share Posted June 8, 2006 (mods: is it possible to get the html codeboxes to preserve indentation, or does the syntax coloring forbid that)I'll tell you before the mods you can't change that becease kaijim is the only one that can and he won't. Thats cool that you can self close any tag or make it 2 tag. For people reading this and saying whats the point of self closing a div? Ever coded rounded corners? This will save a fair bit of code thank you justsomeguy! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now