Embedding Flash Files With Valid XHTML (Strict)

I’m sure a lot of people want to know the answer to this problem, it’s just like “How do I do a target="" without breaking my validation?” problem. The answer to the questions are hard to find or hard to implement but lucky for you adding SWF files isn’t hard at all. The biggest problem with the code you get from Dreamweaver is that they add a lot of outdated code to make it “work better with Internet Explorer”. These days that code is completely unnecessary because people who aren’t using the latest browsers don’t really deserve to see your content anyway! Even the Pentium 3 that I have beside me runs IE7 and Opera just dandy.

So here it is, how to embed SWF files while keeping your XHTML valid:

Dreamweaver generated code for SWF

Valid code for XHTML (transitional)

Instructions

  • Remove the embed tag, it isn’t needed and it doesn’t validate.
  • The classid tells Internet Explorer which player to use, fortunately, Flash Player responds to type=”application/x-shockwave-flash” as well, so we can remove this ugly line.
  • The codebase attribute is optional.
  • The only one left: the data-element, it tells Mozilla and Opera where the music is located since they won’t get it out of the param-element.

Comments are closed.