objectwith valid code
The typical method to include multimedia in a Web page is the
embed element (details). Nearly every known graphical browser supports it, but embed has never been part of the HTML or XHTML specs.
If you use
embed on a conventional HTML or XHTML page, you can never achieve valid code as required by Priority 2 of the Web Content Accessibility Guidelines:
The preferred method to add multimedia, according to the specs, is the
object element. With its many possible forms of alternate content, it’s a useful replacement in accessibility terms – or would be if Internet Explorer on Windows handled it reliably, which it does not.
Your choice as an author, then, is to use a noncompliant method (
embed) that works everywhere or a compliant method (
object) that breaks down in the browser used by 90% of people on the Web. A Solomonic choice at best – and one that has been partially solved by standards-compliant developers.
In solving this problem, developers should at least test a pure-
object approach with their target audience. On a corporate intranet where everyone uses the same browser,
object could be made to work under some circumstances, for example. In this way, developers can make every effort to follow the letter and spirit of the standard.
object element can be used in some cases. One method uses nested
object elements and CSS hacks to include multimedia in a page. It works in many browsers, according to its author’s testing.
If, however, testing proves there are incompatibilities with a pure-standards approach, some other alternatives are available.
Drew McLellan developed a method to use nested
object elements to add a Flash file to a Web page. This Flash Satay technique is something of a hack, but it’s valid code and is in use on real-world sites (e.g., University of Florida, WDDG, Torbytes).
Writing at A List Apart in July 2006, Elizabeth Castro explains how she uses a pure-
object approach that makes Windows Media and QuickTime files play adequately while retaining valid code.
“Object Embedding” by Jessey et. al.
Many authors will wish to adhere strictly to the W3C’s published document types. Some standards-compliant Web developers insist on such adherence, but it is not absolutely necessary. The Web Content Accessibility Guidelines merely require adherence to spec. But HTML is based on SGML and can be extended; XHTML is also XML, which is by definition eXtensible. Thus, authors may write their own document-type definitions (DTDs). This isn’t cheating; it’s using the extensible nature of the specifications to suit a problem not anticipated in the existing W3C DTDs.
In both HTML and XHTML, authors simply need to write a DTD and include it in a page through a
DOCTYPE (document type). The declaration specifies the
embed element and its parameters, making it legal for that page if used according to that spec.
embed? (View source there.) “It uses IE comments and validates.”
embedto HTML (and text-format version of the DTD).
embed, but neither the HTML (plain/fussy) nor the XHTML (plain/fussy) DTDs validates.
document.write() HTML or XHTML code into a document, as in Jeremy Keith’s example. This may be the least-desirable workaround in that it makes potentially-invalid code invisible to validators, which can’t complain about what they can’t detect.