Want a free year on Tuts+ (worth $180)? Start an InMotion Hosting plan for $3.49/mo.
You create your site the right way. You follow all of the rules, so that in the end, you can proudly have a link to w3's validator, confirming your site's perfection. There's just one problem: if you embed any flash into your page, you'll get several errors. That's because the embed tag is not a valid tag. You need to insert your flash the correct way!
What Not To Do
<embed src="player.swf" width="300" height="300" allowscriptaccess="always" allowfullscreen="true" />
This is the simplified version. If you generate the default HTML web page directly from flash, it's ten times more ugly. In fact, it just might be longer than this article - Just to embed a single flash file! And it doesn't even do it with valid HTML (in fact 19 errors).
This is the result. As you can see, there are 6 errors. All 6 from the embed element (5 from the
attributes, and 1 from the tag itself)
What You Should Do
First of all, you shouldn't use the embed tag at all. Forget it! Since we don't have "embed" any more, we're only left with the object tag. It's a good thing that all browsers support it in some way!
Within the Object tag we will use the following attributes:
We'll need to specify the MIME type of what we're inserting. In this case, we're inserting flash. So for the type attribute, we specify "application/x-shockwave-flash". We declare the source through the data attribute. I think everyone can guess what the width and height attributes do. So this is how you should insert your flash, for validity:
<object type="application/x-shockwave-flash" data="flash.swf" width="750" height="400"> <param name="movie" value="flash.swf" /> </object>
You still need the <param> tag as well. Let's test this new code now:
Isn't that "congratulations page" just so...validating? No pun intended. Anyway, I hope you found this to be useful, and have a great week!