maybe i haven't asked before... embed is not really an official HTML 3.2 or 4.0 element... and it doesn't have a close tag </embed> isn't that true? on the other hand, <iframe> always requires a matching closing tag </iframe> or else it will be taken as things to display when iframe is not supported. is there a spec for the embed tag?
<embed> was invented by Netscape, and was never part of actual HTML specs. Some other browsers support it but it's unreliable. You can use <object> instead. This page has a good tutorial on changing Flash HTML code so that it's cross-browser compliant and valid. And yes you should enclose your iframe stuff in <iframe></iframe>. More info about official iframe specs here.
oh thanks for your info... now by the since i used test embed objs a lot, it seems to work in IE, Firefox, Safari, Opera and Maxthon... does any browser actually not accept it?
If you read the Satay article, you'll see the "Twice-baked method" which most people use to make sure everyone gets it-- object for IE and embed for the Mozilla versions. The question you want to ask yourself is, do you care about validation? Embed is not valid (though there's plans for it or something like it in I think HTML5... but who knows when that's coming), but it's been used longer and seems to work. Now, I've used Satay for some banners and whatnot, and after an Opera upgrade, everything worked (except for the whole IE asking to Continue Loading this Page?). People who use the SWFObject, or the Satay method, or whatever else, are doing it not because embed didn't work, but because it wasn't valid and for whatever reason people wanted to validate their sites. Remember that validation doesn't have much to do with something working (well, it does, but it doesn't). Lots of invalid things work. Lots of valid things don't work. The main problem being that browsers are lenient when errors occur, do not stop what they're doing and say, ERROR! (like they should).. instead, they try to guess what you really meant, and actually they are often quite good at it. So, it's a matter of either pride, or requirements. If you use embed, use object around it for IE. If you care about validation, don't use embed. I think this is your choice.
Use OBJECT instead of EMBED (not sufficiently supported) Bellow is an example of correctly embedded flash using OBJECT:
It's true, invalid things often work fine. And actually <embed> was a pretty good idea, maybe the one good thing about Microsoft's 90's browser nonsense (which is still serving to hurt the internet and hold back design, but I digress). But validation is a good habit to get into. Hopefully in the future browsers will all be programmed to follow specs exactly (shortly after Microsoft goes bankrupt ), and it's good to have such things centralized and consistent. Using tags and other HTML that isn't supported may be fine now, but look at the problems that doing so in the past has led to - a big part of web design is accommodating the flaws and differences of various browsers. A big part of what I do, coding PSDs into HTML, isn't the actual coding, it's going around to various browsers and getting things consistent. Valid HTML doesn't fix all these things - but it fixes a lot of them, and makes it much easier to decode when something isn't working. At the very least, it can tell you when you ended up with an extra </div> that is screwing everything up!
Ehm... OBJECT works just fine in all browsers - check my code above No need for EMBED in HTML5 - I hope they won't implement it again when we already have working valid solution...
Object has some issues... and I don't know why they are bringing embed into the specs, I heard it from a guy at Opera. Object was the better idea but browser implementation is clunky. I still find that simple things like transparent backgrounds on Flash can make some browsers up-chuck, while others are fine and still others can't decide whether to put the Flash in front of other objects or in back... ignoring z-index completely. Possibly they mean to replace object with embed? But I just don't know. Anyway, I'll be collecting senior pension before HTML5 is out anyway. And I'd never in my life use the code above. It's got more code than needed. I'll work around IE's issues for rendering, but I'm not adding "codebase" to any of my pages just to get a Flash banner going. I use 5 lines of code and two of those lines is for the "backup" text and images for when there's no Flash player.